Convert ints to size_t to fix CodeQL alerts

This commit is contained in:
Alex Spataru 2021-11-07 23:26:14 -06:00
parent 0d08bf116c
commit 8fedfde2e4
7 changed files with 42 additions and 24 deletions

View File

@ -40,7 +40,8 @@ Window {
property bool firstChange: true
property bool windowMaximized: false
property alias fullScreen: border.fullScreen
readonly property int customFlags: Qt.Window | Qt.CustomizeWindowHint
readonly property int customFlags: Qt.Dialog |
Qt.FramelessWindowHint
//
// Toggle fullscreen state
@ -199,6 +200,18 @@ Window {
}
}
//
// Background color implementation
//
Rectangle {
z: 100
border.width: 0
color: "transparent"
border.color: "#000"
radius: root.radius
anchors.fill: parent
}
//
// Bottom resize handle
//

View File

@ -181,7 +181,9 @@ namespace
m_x1 = m_x0 + m_numColumns * m_dx;
m_y1 = m_y0 + m_numRows * m_dy;
m_entries = ( Entry* )::calloc( m_numRows * m_numColumns, sizeof( Entry ) );
size_t r = static_cast<size_t>(m_numRows);
size_t c = static_cast<size_t>(m_numColumns);
m_entries = ( Entry* )::calloc( r * c, sizeof( Entry ) );
if ( m_entries == NULL )
{
qWarning() << "QwtPlotVectorField: raster for filtering too fine - running out of memory";

View File

@ -220,8 +220,9 @@ void QwtWidgetOverlay::updateMask()
// A fresh buffer from calloc() is usually faster
// than reinitializing an existing one with
// QImage::fill( 0 ) or memset()
m_data->rgbaBuffer = ( uchar* )::calloc( width() * height(), 4 );
size_t w = static_cast<uchar>(width());
size_t h = static_cast<uchar>(width());
m_data->rgbaBuffer = ( uchar* )::calloc( w * h, 4 );
QImage image( m_data->rgbaBuffer,
width(), height(), qwtMaskImageFormat() );

View File

@ -287,6 +287,7 @@ void Misc::ModuleManager::initializeQmlInterface()
// Load main.qml
setSplashScreenMessage(tr("Loading user interface..."));
engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
qApp->processEvents();
// Warning! Do not call setSplashScreenMessage() after loading QML user interface
}
@ -358,15 +359,7 @@ void Misc::ModuleManager::setRenderingEngine(const int engine)
// Restart application
if (ans == QMessageBox::Yes)
{
#ifdef Q_OS_MAC
auto bundle = qApp->applicationDirPath() + "/../../";
QProcess::startDetached("open", { "-n", "-a", bundle });
#else
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
#endif
qApp->exit();
}
Misc::Utilities::rebootApplication();
}
}

View File

@ -96,15 +96,7 @@ void ThemeManager::setTheme(const int id)
// Restart application
if (ans == QMessageBox::Yes)
{
#ifdef Q_OS_MAC
auto bundle = qApp->applicationDirPath() + "/../../";
QProcess::startDetached("open", { "-n", "-a", bundle });
#else
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
#endif
qApp->exit();
}
Utilities::rebootApplication();
}
/**

View File

@ -45,13 +45,29 @@ Utilities *Utilities::getInstance()
return UTILITIES;
}
void Utilities::rebootApplication()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qApp->exit();
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
#else
#ifdef Q_OS_MAC
auto bundle = qApp->applicationDirPath() + "/../../";
QProcess::startDetached("open", { "-n", "-a", bundle });
#else
QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
#endif
qApp->exit();
#endif
}
bool Utilities::askAutomaticUpdates()
{
const int result = showMessageBox(tr("Check for updates automatically?"),
tr("Should %1 automatically check for updates? "
"You can always check for updates manually from "
"the \"Help\" menu")
.arg(APP_NAME),
.arg(APP_NAME),
APP_NAME, QMessageBox::Yes | QMessageBox::No);
return result == QMessageBox::Yes;
}
@ -108,7 +124,7 @@ void Utilities::revealFile(const QString &pathToReveal)
scriptArgs << QLatin1String("-e")
<< QString::fromLatin1(
"tell application \"Finder\" to reveal POSIX file \"%1\"")
.arg(pathToReveal);
.arg(pathToReveal);
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
scriptArgs.clear();
scriptArgs << QLatin1String("-e")

View File

@ -44,6 +44,7 @@ class Utilities : public QObject
public:
// clang-format off
static Utilities* getInstance();
static void rebootApplication();
Q_INVOKABLE bool askAutomaticUpdates();
static int showMessageBox(QString text,
QString informativeText,