[education/rkward] rkward: Fix some cppcheck warnings
Thomas Friedrichsmeier
null at kde.org
Sat Sep 7 10:22:47 BST 2024
Git commit 80c019c777129b3fe46315e554ff0d94d4911479 by Thomas Friedrichsmeier.
Committed on 07/09/2024 at 09:21.
Pushed by tfry into branch 'master'.
Fix some cppcheck warnings
M +2 -2 rkward/rbackend/rkrbackendprotocol_backend.h
M +1 -1 rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
M +1 -1 rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
M +4 -1 rkward/rkward.cpp
M +5 -5 rkward/scriptbackends/rkcomponentscripting.cpp
M +2 -1 rkward/windows/rkcodecompletion.cpp
https://invent.kde.org/education/rkward/-/commit/80c019c777129b3fe46315e554ff0d94d4911479
diff --git a/rkward/rbackend/rkrbackendprotocol_backend.h b/rkward/rbackend/rkrbackendprotocol_backend.h
index 076ac6871..860259cca 100644
--- a/rkward/rbackend/rkrbackendprotocol_backend.h
+++ b/rkward/rbackend/rkrbackendprotocol_backend.h
@@ -24,8 +24,8 @@ int do_main(int, char**, void*, void* (*)(void*, const char*));
class RKRBackendProtocolBackend {
public:
static bool inRThread ();
- static QString dataDir () { return _instance->data_dir; };
- static QString rkdServerName () { return _instance->rkd_server_name; };
+ static const QString& dataDir () { return _instance->data_dir; };
+ static const QString& rkdServerName () { return _instance->rkd_server_name; };
static QString backendDebugFile ();
static void doExit();
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
index e2b589e5d..e3c09123f 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
@@ -501,7 +501,7 @@ void RKGraphicsDevice::text(double x, double y, const QString& text, double rot,
triggerUpdate();
}
-QString RKGraphicsDevice::glyph(const QString &font, quint8 index, const QString &family, quint32 weight, QFont::Style style, double size, const QColor &col, double rot, QVector<QPointF> points, QVector<quint32> glyphs) {
+QString RKGraphicsDevice::glyph(const QString &font, quint8 index, const QString &family, quint32 weight, QFont::Style style, double size, const QColor &col, double rot, const QVector<QPointF>& points, const QVector<quint32>& glyphs) {
RK_TRACE(GRAPHICS_DEVICE);
RK_ASSERT(points.size() == glyphs.size());
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
index 62aee1013..cb798c18b 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
@@ -51,7 +51,7 @@ public:
void rect (const QRectF& rec, const QPen& pen, const QBrush& brush);
QSizeF strSize (const QString &text, const QFont& font);
void text (double x, double y, const QString &text, double rot, double hadj, const QColor& col, const QFont& font);
- QString glyph(const QString &font, quint8 index, const QString &family, quint32 weight, QFont::Style style, double size, const QColor &col, double rot, QVector<QPointF> points, QVector<quint32> glyphs);
+ QString glyph(const QString &font, quint8 index, const QString &family, quint32 weight, QFont::Style style, double size, const QColor &col, double rot, const QVector<QPointF>& points, const QVector<quint32>& glyphs);
void metricInfo (const QChar& c, const QFont& font, double *ascent, double *descent, double *width);
void setClip (const QRectF& new_clip);
void polygon (const QPolygonF& pol, const QPen& pen, const QBrush &brush);
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index baeb4b766..6c39cdc13 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -379,7 +379,10 @@ void RKWardMainWindow::startR () {
QString package = QDir (packages_path).absoluteFilePath (packages[i]);
if (RKSettingsModuleGeneral::rkwardVersionChanged() || RKCommandLineArgs::get(RKCommandLineArgs::Setup).toBool()) {
RK_DEBUG(APP, DL_INFO, "RKWard version changed or setup requested. Discarding cached package at %s", qPrintable(package));
- if(QFileInfo::exists(package)) RK_ASSERT(QFile::remove(package));
+ if(QFileInfo::exists(package)) {
+ bool rem = QFile::remove(package);
+ RK_ASSERT(rem);
+ }
}
if (!QFileInfo::exists(package)) {
QString source = RKCommonFunctions::getRKWardDataDir() + "/rpackages/" + packages[i];
diff --git a/rkward/scriptbackends/rkcomponentscripting.cpp b/rkward/scriptbackends/rkcomponentscripting.cpp
index 3f788519c..48de80829 100644
--- a/rkward/scriptbackends/rkcomponentscripting.cpp
+++ b/rkward/scriptbackends/rkcomponentscripting.cpp
@@ -144,8 +144,8 @@ QVariant RKComponentScriptingProxy::doRCommand (const QString& command, const QS
return (QVariant (com.command->id ()));
}
-static QJSValue marshall (QJSEngine *engine, RData *data) {
- RK_TRACE (PHP);
+static QJSValue marshall(QJSEngine *engine, const RData *data) {
+ RK_TRACE(PHP);
if (data->getDataType() == RData::StringVector) {
return (rkJSMakeArray(engine, data->stringVector()));
@@ -157,13 +157,13 @@ static QJSValue marshall (QJSEngine *engine, RData *data) {
const RData::RDataStorage& rs = data->structureVector();
QJSValue ret = engine->newArray (rs.size ());
for (int i = 0; i < rs.size (); ++i) {
- ret.setProperty (i, marshall (engine, rs[i]));
+ ret.setProperty(i, marshall(engine, rs[i]));
}
return ret;
} else {
- RK_ASSERT (false);
+ RK_ASSERT(false);
}
- return QJSValue ();
+ return QJSValue();
}
void RKComponentScriptingProxy::scriptRCommandFinished (RCommand* command) {
diff --git a/rkward/windows/rkcodecompletion.cpp b/rkward/windows/rkcodecompletion.cpp
index dca5110f9..011249485 100644
--- a/rkward/windows/rkcodecompletion.cpp
+++ b/rkward/windows/rkcodecompletion.cpp
@@ -301,7 +301,8 @@ void RKCompletionManager::updateVisibility () {
void RKCompletionManager::modelGainedLateData(RKCompletionModelBase* model) {
RK_TRACE (COMMANDEDITOR);
- RK_ASSERT(started_models.removeAll(model)); // should have been started before, thus be in the list
+ bool removed = started_models.removeAll(model);
+ RK_ASSERT(removed); // should have been started before, thus be in the list
startModel(model, true, model->completionRange(view(), view()->cursorPosition()));
}
More information about the rkward-tracker
mailing list