[education/rkward] rkward: Clazy warnings

Thomas Friedrichsmeier null at kde.org
Thu Jun 9 15:30:34 BST 2022


Git commit 1b32351d411ea96fa3abd1d98ffaa1172e5ea79a by Thomas Friedrichsmeier.
Committed on 09/06/2022 at 14:29.
Pushed by tfry into branch 'master'.

Clazy warnings

M  +1    -1    rkward/core/robject.cpp
M  +4    -3    rkward/misc/rkstandardactions.cpp
M  +1    -1    rkward/rbackend/rkrsupport.cpp
M  +1    -1    rkward/rbackend/rkrsupport.h
M  +2    -2    rkward/rkward.cpp
M  +3    -3    rkward/settings/rkrecenturls.cpp
M  +2    -2    rkward/windows/rkhtmlwindow.cpp

https://invent.kde.org/education/rkward/commit/1b32351d411ea96fa3abd1d98ffaa1172e5ea79a

diff --git a/rkward/core/robject.cpp b/rkward/core/robject.cpp
index 0542b084..2c3b6e61 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -43,7 +43,7 @@ public:
 	}
 	void addCommandFinishedCallback(RCommand *command, std::function<void(RCommand*)> callback) {
 		++command_count;
-		QObject::connect(command->notifier(), &RCommandNotifier::commandFinished, [this, callback](RCommand* command) {
+		QObject::connect(command->notifier(), &RCommandNotifier::commandFinished, [this, callback](RCommand* command) { // clazy:exclude=connect-3arg-lambda
 			if (object) {
 				callback(command);
 			}
diff --git a/rkward/misc/rkstandardactions.cpp b/rkward/misc/rkstandardactions.cpp
index a00d576a..4003cac7 100644
--- a/rkward/misc/rkstandardactions.cpp
+++ b/rkward/misc/rkstandardactions.cpp
@@ -130,11 +130,12 @@ public slots:
 		container = new QMenu;
 		actions->addWebShortcutsToMenu(container);
 		QList<QAction*> actions;
-		if (container->actions().count() == 1) {
-			QMenu *internal = container->actions().first()->menu();
+		auto cactions = container->actions();
+		if (cactions.count() == 1) {
+			QMenu *internal = cactions.first()->menu();
 			if (internal) actions = internal->actions();
 		}
-		if (actions.isEmpty()) actions = container->actions();
+		if (actions.isEmpty()) actions = cactions;
 		for (int i = 0; i < actions.count(); ++i) {
 			menu->addAction(actions[i]);
 		}
diff --git a/rkward/rbackend/rkrsupport.cpp b/rkward/rbackend/rkrsupport.cpp
index 1d07f4bd..7d40112c 100644
--- a/rkward/rbackend/rkrsupport.cpp
+++ b/rkward/rbackend/rkrsupport.cpp
@@ -284,7 +284,7 @@ RData *RKRSupport::SEXPToRData (SEXP from_exp) {
 }
 
 SEXP RKRShadowEnvironment::shadowenvbase = nullptr;
-QMap<SEXP, RKRShadowEnvironment*> RKRShadowEnvironment::environments;
+QHash<SEXP, RKRShadowEnvironment*> RKRShadowEnvironment::environments;
 RKRShadowEnvironment* RKRShadowEnvironment::environmentFor(SEXP baseenvir) {
 	RK_TRACE(RBACKEND);
 	// TODO: probably R_GlobalEnv should be special-cased, as this is what we'll check most often (or exclusively?)
diff --git a/rkward/rbackend/rkrsupport.h b/rkward/rbackend/rkrsupport.h
index bd203c67..5385ec6e 100644
--- a/rkward/rbackend/rkrsupport.h
+++ b/rkward/rbackend/rkrsupport.h
@@ -54,7 +54,7 @@ private:
 	void updateSymbolCache(const QString &name);
 	SEXP baseenvir;
 	SEXP shadowenvir;
-	static QMap<SEXP, RKRShadowEnvironment*> environments;
+	static QHash<SEXP, RKRShadowEnvironment*> environments;
 	static SEXP shadowenvbase;
 };
 
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 1720237f..951796c6 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -131,7 +131,7 @@ RKWardMainWindow::RKWardMainWindow () : KParts::MainWindow ((QWidget *)0, (Qt::W
 	RKWorkplace::mainWorkplace ()->initActions (actionCollection ());
 	setCentralWidget (RKWorkplace::mainWorkplace ());
 	connect (RKWorkplace::mainWorkplace ()->view (), &RKWorkplaceView::captionChanged, this, static_cast<void (RKWardMainWindow::*)(const QString&)>(&RKWardMainWindow::setCaption));
-	connect (RKWorkplace::mainWorkplace (), &RKWorkplace::workspaceUrlChanged, [this](const QUrl &url) { RKRecentUrls::addRecentUrl(RKRecentUrls::workspaceId(), url); setCaption(QString()); });
+	connect (RKWorkplace::mainWorkplace (), &RKWorkplace::workspaceUrlChanged, this, [this](const QUrl &url) { RKRecentUrls::addRecentUrl(RKRecentUrls::workspaceId(), url); setCaption(QString()); });
 	initStatusBar();
 
 	part_manager = new KParts::PartManager (this);
@@ -645,7 +645,7 @@ void RKWardMainWindow::initActions() {
 				restart_now();
 			} else {
 				RCommand *c = new RCommand(QString(), RCommand::QuitCommand);
-				c->whenFinished(this, [restart_now]() { QTimer::singleShot(0, restart_now); });
+				c->whenFinished(this, [this, restart_now]() { QTimer::singleShot(0, this, restart_now); });
 				RInterface::issueCommand(c);
 			}
 		}
diff --git a/rkward/settings/rkrecenturls.cpp b/rkward/settings/rkrecenturls.cpp
index 0b1e8b50..08985865 100644
--- a/rkward/settings/rkrecenturls.cpp
+++ b/rkward/settings/rkrecenturls.cpp
@@ -19,11 +19,11 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 #include "../debug.h"
 
-static QString _scripts_id("rscripts");
+static QString _scripts_id("rscripts");  // clazy:exclude=non-pod-global-static
 QString RKRecentUrls::scriptsId() { return _scripts_id; }
-static QString _workspace_id("workspaces");
+static QString _workspace_id("workspaces");  // clazy:exclude=non-pod-global-static
 QString RKRecentUrls::workspaceId() { return _workspace_id; }
-static QString _output_id("rkoutput");
+static QString _output_id("rkoutput");  // clazy:exclude=non-pod-global-static
 QString RKRecentUrls::outputId() { return _output_id; }
 
 QHash<QString, KRecentFilesAction*> RKRecentUrls::actions;
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 3cafac45..fec23b48 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -624,12 +624,12 @@ bool RKHTMLWindow::handleRKWardURL (const QUrl &url, RKHTMLWindow *window) {
 				RKWardMainWindow::getMain()->slotOpenCommandEditor(target);
 			} else if (category == RKRecentUrls::workspaceId()) {
 				// This window will be destroyed while closing the previous workspace. Thus wait for the next event cycle.
-				QTimer::singleShot(0, [target]() { RKWardMainWindow::getMain()->askOpenWorkspace(target); });
+				QTimer::singleShot(0, RKWardMainWindow::getMain(), [target]() { RKWardMainWindow::getMain()->askOpenWorkspace(target); });
 			} else if (category == RKRecentUrls::outputId()) {
 				RKWardMainWindow::getMain()->slotOpenOutput(target);
 			} else {
 				// See opening workspace, above.
-				QTimer::singleShot(0, [target]() { RKWorkplace::mainWorkplace()->openAnyUrl(target); });
+				QTimer::singleShot(0, RKWardMainWindow::getMain(), [target]() { RKWorkplace::mainWorkplace()->openAnyUrl(target); });
 			}
 		} else if (url.host () == "actions") {  // anything else
 			QString action = url.path ();



More information about the rkward-tracker mailing list