[education/rkward] rkward/scriptbackends: Remove deprecated QLinkedList

Thomas Friedrichsmeier null at kde.org
Sun Apr 17 22:16:12 BST 2022


Git commit 079ae64db3d9994a984a304efee89c4ff1baabf7 by Thomas Friedrichsmeier.
Committed on 17/04/2022 at 20:09.
Pushed by tfry into branch 'master'.

Remove deprecated QLinkedList

M  +11   -10   rkward/scriptbackends/qtscriptbackend.cpp
M  +6    -5    rkward/scriptbackends/scriptbackend.cpp
M  +4    -4    rkward/scriptbackends/scriptbackend.h
M  +8    -8    rkward/scriptbackends/simplebackend.cpp

https://invent.kde.org/education/rkward/commit/079ae64db3d9994a984a304efee89c4ff1baabf7

diff --git a/rkward/scriptbackends/qtscriptbackend.cpp b/rkward/scriptbackends/qtscriptbackend.cpp
index a4c9487e..c688a2b4 100644
--- a/rkward/scriptbackends/qtscriptbackend.cpp
+++ b/rkward/scriptbackends/qtscriptbackend.cpp
@@ -99,26 +99,27 @@ void QtScriptBackend::destroy () {
 void QtScriptBackend::tryNextFunction () {
 	RK_TRACE (PHP);
 
-	if (script_thread && (!busy) && (!command_stack.isEmpty ())) {
+	if (script_thread && (!busy) && (!command_stack.empty())) {
 	/// clean up previous command if applicable
-		if (command_stack.first ()->complete) {
-			delete command_stack.takeFirst ();
+		if (command_stack.front()->complete) {
+			delete command_stack.front();
+			command_stack.pop_front();
 			
-			if (command_stack.isEmpty ()) {
+			if (command_stack.empty ()) {
 				script_thread->goToSleep (true);
 				return;
 			}
 		}
 		
-		RK_DEBUG (PHP, DL_DEBUG, "submitting QtScript code: %s", command_stack.first ()->command.toLatin1 ().data ());
+		RK_DEBUG(PHP, DL_DEBUG, "submitting QtScript code: %s", qPrintable(command_stack.front()->command));
 		if (script_thread) script_thread->goToSleep (false);
-		script_thread->setCommand (command_stack.first ()->command);
+		script_thread->setCommand(command_stack.front()->command);
 		busy = true;
-		command_stack.first ()->complete = true;
-		current_flags = command_stack.first ()->flags;
-		current_type = command_stack.first ()->type;
+		command_stack.front()->complete = true;
+		current_flags = command_stack.front()->flags;
+		current_type = command_stack.front()->type;
 	} else {
-		if (script_thread && command_stack.isEmpty ()) script_thread->goToSleep (true);
+		if (script_thread && command_stack.empty()) script_thread->goToSleep (true);
 	}
 }
 
diff --git a/rkward/scriptbackends/scriptbackend.cpp b/rkward/scriptbackends/scriptbackend.cpp
index 5bb3e17e..23fde6a3 100644
--- a/rkward/scriptbackends/scriptbackend.cpp
+++ b/rkward/scriptbackends/scriptbackend.cpp
@@ -19,8 +19,9 @@ ScriptBackend::ScriptBackend () : QObject() {
 }
 
 ScriptBackend::~ScriptBackend () {
-	while (command_stack.count ()) {
-		delete command_stack.takeFirst ();
+	while (!command_stack.empty()) {
+		delete command_stack.front();
+		command_stack.pop_front();
 	}
 }
 
@@ -47,7 +48,7 @@ void ScriptBackend::callFunction (const QString &function, int flags, int type)
 		invalidateCalls (type);
 	}
 
-	command_stack.append (command);
+	command_stack.push_back(command);
 	tryNextFunction ();
 }
 
@@ -58,8 +59,8 @@ void ScriptBackend::invalidateCalls (int type) {
 		current_type = Ignore;
 	}
 
-	QLinkedList<ScriptCommand *>::iterator it = command_stack.begin ();
-	while (it != command_stack.end ()) {
+	auto it = command_stack.begin();
+	while (it != command_stack.end()) {
 		if ((*it)->type == type) {
 			delete (*it);
 			it = command_stack.erase (it);		// it now points to next item
diff --git a/rkward/scriptbackends/scriptbackend.h b/rkward/scriptbackends/scriptbackend.h
index 943478ed..2be2e5c3 100644
--- a/rkward/scriptbackends/scriptbackend.h
+++ b/rkward/scriptbackends/scriptbackend.h
@@ -7,10 +7,10 @@ SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef SCRIPTBACKEND_H
 #define SCRIPTBACKEND_H
 
-#include <qobject.h>
+#include <list>
 
-#include <qstring.h>
-#include <QLinkedList>
+#include <QObject>
+#include <QString>
 
 #include "../plugin/rkstandardcomponent.h"
 
@@ -72,7 +72,7 @@ protected:
 	/// whether command has finished
 		bool complete;
 	};
-	QLinkedList<ScriptCommand *> command_stack;
+	std::list<ScriptCommand *> command_stack;
 
 	int current_flags;
 	int current_type;
diff --git a/rkward/scriptbackends/simplebackend.cpp b/rkward/scriptbackends/simplebackend.cpp
index 87c46ef2..7e6e7805 100644
--- a/rkward/scriptbackends/simplebackend.cpp
+++ b/rkward/scriptbackends/simplebackend.cpp
@@ -67,19 +67,19 @@ void SimpleBackend::writeData (const QVariant &data) {
 void SimpleBackend::tryNextFunction () {
 	RK_TRACE (PHP);
 
-	if ((!busy) && (!command_stack.isEmpty ())) {
+	if ((!busy) && (!command_stack.empty())) {
 		// clean up previous command if applicable
-		if (command_stack.first ()->complete) {
-			delete command_stack.first ();
-			command_stack.pop_front ();
+		if (command_stack.front()->complete) {
+			delete command_stack.front();
+			command_stack.pop_front();
 
-			if (!command_stack.count ()) return;
+			if (command_stack.empty()) return;
 		}
 
 		busy = true;
-		command_stack.first ()->complete = true;
-		current_flags = command_stack.first ()->flags;
-		current_type = command_stack.first ()->type;
+		command_stack.front()->complete = true;
+		current_flags = command_stack.front()->flags;
+		current_type = command_stack.front()->type;
 
 		current_values.clear ();
 		template_pos = 0;



More information about the rkward-tracker mailing list