[education/rkward] rkward: Some more cppcheck warnings

Thomas Friedrichsmeier null at kde.org
Sun May 12 16:29:42 BST 2024


Git commit e44d547491642524c31c3bae0d2c1f633d7d1058 by Thomas Friedrichsmeier.
Committed on 12/05/2024 at 15:19.
Pushed by tfry into branch 'master'.

Some more cppcheck warnings

M  +0    -2    rkward/core/robject.cpp
M  +1    -2    rkward/dialogs/rkerrordialog.cpp
M  +1    -1    rkward/misc/rkoutputdirectory.cpp
M  +6    -6    rkward/plugin/rkmatrixinput.cpp
M  +1    -1    rkward/rbackend/rkrsupport.cpp
M  +1    -1    rkward/rkconsole.cpp
M  +1    -1    rkward/windows/rkwindowcatcher.cpp
M  +2    -2    rkward/windows/rkworkplaceview.cpp

https://invent.kde.org/education/rkward/-/commit/e44d547491642524c31c3bae0d2c1f633d7d1058

diff --git a/rkward/core/robject.cpp b/rkward/core/robject.cpp
index dcbdf6959..c1605cf09 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -560,7 +560,6 @@ int RObject::getObjectModelIndexOf (RObject *child) const {
 	}
 	if (isType (Workspace)) {
 		if (child == static_cast<const RObjectList*> (this)->orphanNamespacesObject ()) return offset;
-		offset += 1;
 	}
 	return -1;
 }
@@ -591,7 +590,6 @@ RObject *RObject::findChildByObjectModelIndex (int index) const {
 	}
 	if (isType (Workspace)) {
 		if (index == 0) return static_cast<const RObjectList *> (this)->orphanNamespacesObject ();
-		--index;
 	}
 	return nullptr;
 }
diff --git a/rkward/dialogs/rkerrordialog.cpp b/rkward/dialogs/rkerrordialog.cpp
index 95add8567..ffbc7d076 100644
--- a/rkward/dialogs/rkerrordialog.cpp
+++ b/rkward/dialogs/rkerrordialog.cpp
@@ -36,10 +36,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 class RKBugzillaReportDialog : public QDialog {
 public:
-	RKBugzillaReportDialog (QWidget* parent, const QString& report_template) : QDialog (parent) {
+	RKBugzillaReportDialog(QWidget* parent, const QString& report_template) : QDialog(parent), report_template(report_template) {
 		RK_TRACE (DIALOGS);
 
-		RKBugzillaReportDialog::report_template = report_template;
 		setWindowTitle (i18n ("Reporting bugs in RKWard"));
 		QVBoxLayout *layout = new QVBoxLayout (this);
 		QLabel *label = RKCommonFunctions::wordWrappedLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Thank you for taking the time to help improve RKWard. To help us "
diff --git a/rkward/misc/rkoutputdirectory.cpp b/rkward/misc/rkoutputdirectory.cpp
index 5f1acf5a3..3ff442c39 100644
--- a/rkward/misc/rkoutputdirectory.cpp
+++ b/rkward/misc/rkoutputdirectory.cpp
@@ -410,7 +410,7 @@ RKOutputDirectoryCallResult RKOutputDirectory::getCurrentOutput(RCommandChain* c
 	if (outputs.isEmpty()) {
 		if (RKSettingsModuleOutput::sharedDefaultOutput()) {
 			QString filename = RKSettingsModuleGeneral::filesPath() + "default.rko";
-			auto ret = get(filename, !QFileInfo::exists(filename), chain);
+			ret = get(filename, !QFileInfo::exists(filename), chain);
 			if (ret.dir()) {
 				ret.dir()->activate(chain);
 				return ret;
diff --git a/rkward/plugin/rkmatrixinput.cpp b/rkward/plugin/rkmatrixinput.cpp
index f2bb18d65..359658ac1 100644
--- a/rkward/plugin/rkmatrixinput.cpp
+++ b/rkward/plugin/rkmatrixinput.cpp
@@ -94,12 +94,12 @@ RKMatrixInput::RKMatrixInput (const QDomElement& element, RKComponent* parent_co
 	}
 
 	// define standard actions
-	QAction *cut = KStandardAction::cut(this, &RKMatrixInput::cut, this);
-	display->addAction(cut);
-	QAction *copy = KStandardAction::copy(this, &RKMatrixInput::copy, this);
-	display->addAction(copy);
-	QAction *paste = KStandardAction::paste(this, &RKMatrixInput::paste, this);
-	display->addAction(paste);
+	QAction *acut = KStandardAction::cut(this, &RKMatrixInput::cut, this);
+	display->addAction(acut);
+	QAction *acopy = KStandardAction::copy(this, &RKMatrixInput::copy, this);
+	display->addAction(acopy);
+	QAction *apaste = KStandardAction::paste(this, &RKMatrixInput::paste, this);
+	display->addAction(apaste);
 	display->setContextMenuPolicy(Qt::ActionsContextMenu);
 
 	display->setRKItemDelegate (new RKItemDelegate (display, model, true));
diff --git a/rkward/rbackend/rkrsupport.cpp b/rkward/rbackend/rkrsupport.cpp
index 765b90632..1d6bdb545 100644
--- a/rkward/rbackend/rkrsupport.cpp
+++ b/rkward/rbackend/rkrsupport.cpp
@@ -256,7 +256,7 @@ RData *RKRSupport::SEXPToRData (SEXP from_exp) {
 		case EXTPTRSXP:
 			if (RFn::R_ExternalPtrTag(from_exp) == RKWard_RData_Tag) {		// our very own data
 				delete data;
-				data = (RData*) RFn::R_ExternalPtrAddr(from_exp);
+				data = static_cast<RData*>(RFn::R_ExternalPtrAddr(from_exp));
 				RFn::R_ClearExternalPtr(from_exp);
 				break;
 			}
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 7f6515463..f9e4e35de 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -367,7 +367,7 @@ bool RKConsole::eventFilter (QObject *o, QEvent *e) {
 	}
 
 	if ((e->type () == QEvent::KeyPress) || (e->type () == QEvent::Shortcut)) {
-		QKeyEvent *k = (QKeyEvent *)e;
+		QKeyEvent *k = static_cast<QKeyEvent *>(e);
 		return (handleKeyPress (k));
 	} else if (e->type () == QEvent::MouseButtonPress) {
 		// we seem to need this, as the kateview will swallow the contextMenuEvent, otherwise
diff --git a/rkward/windows/rkwindowcatcher.cpp b/rkward/windows/rkwindowcatcher.cpp
index 3316945e2..5133fe2cb 100644
--- a/rkward/windows/rkwindowcatcher.cpp
+++ b/rkward/windows/rkwindowcatcher.cpp
@@ -812,7 +812,7 @@ RKCaughtX11WindowPart::RKCaughtX11WindowPart(RKCaughtX11Window *window) : KParts
 	action = actionCollection()->addAction("device_copy_to_output", window, &RKCaughtX11Window::copyDeviceToOutput);
 	action->setText (i18n ("Copy to output"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowOutput));
-	action = actionCollection()->addAction(KStandardAction::Print, "device_print", window, &RKCaughtX11Window::printDevice);
+	actionCollection()->addAction(KStandardAction::Print, "device_print", window, &RKCaughtX11Window::printDevice);
 	action = actionCollection()->addAction("device_copy_to_r_object", window, &RKCaughtX11Window::copyDeviceToRObject);
 	action->setText (i18n ("Store as R object..."));
 	action = actionCollection()->addAction("device_duplicate", window, &RKCaughtX11Window::duplicateDevice);
diff --git a/rkward/windows/rkworkplaceview.cpp b/rkward/windows/rkworkplaceview.cpp
index df859a4fa..7dbf18ce0 100644
--- a/rkward/windows/rkworkplaceview.cpp
+++ b/rkward/windows/rkworkplaceview.cpp
@@ -235,14 +235,14 @@ RKWorkplaceViewPane* RKWorkplaceView::activePane () const {
 void RKWorkplaceView::initActions (KActionCollection *ac) {
 	RK_TRACE (APP);
 
-	action_page_left = (QAction *) ac->addAction("left_window", this, &RKWorkplaceView::pageLeft);
+	action_page_left = ac->addAction("left_window", this, &RKWorkplaceView::pageLeft);
 	action_page_left->setText (i18n ("Window Left"));
 	ac->setDefaultShortcuts (action_page_left, {
 		Qt::ControlModifier | Qt::Key_Less,
 		Qt::ControlModifier | Qt::Key_Comma
 	});
 
-	action_page_right = (QAction *) ac->addAction("right_window", this, &RKWorkplaceView::pageRight);
+	action_page_right = ac->addAction("right_window", this, &RKWorkplaceView::pageRight);
 	action_page_right->setText (i18n ("Window Right"));
 	ac->setDefaultShortcuts (action_page_right, {
 		Qt::ControlModifier | Qt::Key_Greater,


More information about the rkward-tracker mailing list