[education/rkward/devel/workspace_output] /: Remove explicit #warnings

Thomas Friedrichsmeier null at kde.org
Sun Nov 8 08:31:19 GMT 2020


Git commit e9b518361fdd93d72c963e6078dccf0a8cd4babc by Thomas Friedrichsmeier.
Committed on 08/11/2020 at 08:31.
Pushed by tfry into branch 'devel/workspace_output'.

Remove explicit #warnings

M  +4    -1    ChangeLog
M  +10   -6    rkward/misc/rkoutputdirectory.cpp
M  +1    -1    rkward/misc/rkoutputdirectory.h
M  +11   -0    rkward/rbackend/rcommand.h
M  +0    -1    rkward/rbackend/rkrinterface.cpp
M  +1    -0    tests/rkward_application_tests.R

https://invent.kde.org/education/rkward/commit/e9b518361fdd93d72c963e6078dccf0a8cd4babc

diff --git a/ChangeLog b/ChangeLog
index f96087b2..0e9684a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,11 @@
+TODOS for autotests:
+  - Check an update the standards.
+  - Use options(warn=1), in order to get warnings into the test?
+
 TODOS for output directories:
   - Make sure not to activate default output while quitting (abouttoquit is too late)
   - save outputs to .rkworkplace and restore them
   - UI
-  - remove explicit warnings
 
 - rkwardtests library gains helper functions for checking for expected errors
 - Internal: Allow R-level calls to support both subcommands, and a return value at the same time
diff --git a/rkward/misc/rkoutputdirectory.cpp b/rkward/misc/rkoutputdirectory.cpp
index 4cd5ae56..9e299a3f 100644
--- a/rkward/misc/rkoutputdirectory.cpp
+++ b/rkward/misc/rkoutputdirectory.cpp
@@ -331,14 +331,15 @@ GenericRRequestResult RKOutputDirectory::purge(RKOutputDirectory::OverwriteBehav
 	dir.removeRecursively();
 	outputs.remove(id);
 	deleteLater();
+	GenericRRequestResult messages;
 	if (active) {
 		if (RKQuitAgent::quittingInProgress()) {
 			RK_DEBUG(APP, DL_DEBUG, "Skipping activation of new output file: quitting in progress");
 		} else {
-			getCurrentOutput(chain)->activate(chain);
+			getCurrentOutput(chain, &messages)->activate(chain);
 		}
 	}
-	return GenericRRequestResult();
+	return messages;
 }
 
 void RKOutputDirectory::purgeAllNoAsk() {
@@ -390,12 +391,13 @@ QList<RKOutputDirectory *> RKOutputDirectory::allOutputs() {
 	return ret;
 }
 
-RKOutputDirectory* RKOutputDirectory::getCurrentOutput(RCommandChain* chain) {
+RKOutputDirectory* RKOutputDirectory::getCurrentOutput(RCommandChain* chain, GenericRRequestResult* message_res) {
 	RK_TRACE(APP);
 
 	if (outputs.isEmpty()) {
 		auto n = createOutputDirectoryInternal();
 		n->activate(chain);
+		if (message_res) message_res->addMessages(GenericRRequestResult(QVariant(), i18n("New empty output directory has been created, automatically")));
 		return n;
 	}
 
@@ -404,10 +406,11 @@ RKOutputDirectory* RKOutputDirectory::getCurrentOutput(RCommandChain* chain) {
 		if (it.value()->isActive()) return it.value();
 		if (it.value()->filename().isEmpty()) candidate = it.value();
 	}
-#warning generate a warning, when a new output is created or activated
+
 	if (!candidate) candidate = outputs[0];
 	RK_ASSERT(candidate);
 	candidate->activate(chain);
+	if (message_res) message_res->addMessages(GenericRRequestResult(QVariant(), i18n("Output has been activated, automatically")));
 	return candidate;
 }
 
@@ -449,11 +452,12 @@ GenericRRequestResult RKOutputDirectory::handleRCall(const QStringList& params,
 		QString filename = params.value(3);
 		bool create = (params.value(2) == QStringLiteral("create"));
 		RKOutputDirectory *out = nullptr;
+		GenericRRequestResult messages;
 		if (filename.isEmpty()) {
 			if (create) {
 				out = createOutputDirectoryInternal();
 			} else {
-				out = getCurrentOutput(chain);
+				out = getCurrentOutput(chain, &messages);
 			}
 		} else {
 			filename = QFileInfo(filename).canonicalFilePath();
@@ -470,7 +474,7 @@ GenericRRequestResult RKOutputDirectory::handleRCall(const QStringList& params,
 				}
 			}
 		}
-		return GenericRRequestResult(out->getId());
+		return GenericRRequestResult(out->getId()).addMessages(messages);
 	} else {
 		// all other commands pass the output id as second parameter. Look that up, first
 		QString id = params.value(1);
diff --git a/rkward/misc/rkoutputdirectory.h b/rkward/misc/rkoutputdirectory.h
index 2d76cb07..8d0d125e 100644
--- a/rkward/misc/rkoutputdirectory.h
+++ b/rkward/misc/rkoutputdirectory.h
@@ -64,7 +64,7 @@ public:
  *  If no output is active, find an activate the next output without a save url.
  *  If that does not exist, activate and return the next existing output.
  *  If that does not exist, create a new output, activate and return it. */
-	static RKOutputDirectory* getCurrentOutput(RCommandChain *chain=0);
+	static RKOutputDirectory* getCurrentOutput(RCommandChain *chain=0, GenericRRequestResult* message_res=0);
 	static QList<RKOutputDirectory*> allOutputs();
 	static void purgeAllNoAsk();
 private:
diff --git a/rkward/rbackend/rcommand.h b/rkward/rbackend/rcommand.h
index 8e63c8a6..afbb3420 100644
--- a/rkward/rbackend/rcommand.h
+++ b/rkward/rbackend/rcommand.h
@@ -244,6 +244,17 @@ struct GenericRRequestResult {
 	static GenericRRequestResult makeError(const QString& error) {
 		return GenericRRequestResult(QVariant(), QString(), error);
 	}
+	GenericRRequestResult& addMessages(const GenericRRequestResult &other) {
+		if (!other.error.isEmpty()) {
+			if (!error.isEmpty()) error.append('\n');
+			error.append(other.error);
+		}
+		if (!other.warning.isEmpty()) {
+			if (!warning.isEmpty()) warning.append('\n');
+			warning.append(other.warning);
+		}
+		return *this;
+	}
 	QString error;
 	QString warning;
 	QVariant ret;
diff --git a/rkward/rbackend/rkrinterface.cpp b/rkward/rbackend/rkrinterface.cpp
index 2d0aa8d9..c2812929 100644
--- a/rkward/rbackend/rkrinterface.cpp
+++ b/rkward/rbackend/rkrinterface.cpp
@@ -749,7 +749,6 @@ void RInterface::processHistoricalSubstackRequest (const QStringList &calllist,
 			RK_ASSERT (false);
 		}
 	} else if (call == QStringLiteral ("output")) {
-#warning Gaaah. This does not work, if a subcommand has been run (request is "used up" in that case)
 		request->setResult(RKOutputDirectory::handleRCall(calllist.mid(1), in_chain));
 	} else {
 		request->setResult(GenericRRequestResult::makeError(i18n("Unrecognized call '%1'", call)));
diff --git a/tests/rkward_application_tests.R b/tests/rkward_application_tests.R
index df6d2331..d4d2e077 100644
--- a/tests/rkward_application_tests.R
+++ b/tests/rkward_application_tests.R
@@ -1,4 +1,5 @@
 ## definition of the test suite
+library("rkwardtests", lib.loc=rk.home("lib"))
 suite <- new ("RKTestSuite", id="rkward_application_tests",
 	# place here libraries that are required for *all* tests in this suite, or highly likely to be installed
 	libraries = character (0),




More information about the rkward-tracker mailing list