[education/rkward] rkward: Fix status display in case of errors

Thomas Friedrichsmeier null at kde.org
Sun Jul 7 17:33:10 BST 2024


Git commit 74038c419cad02c691ef408e46f38f4161701bc1 by Thomas Friedrichsmeier.
Committed on 07/07/2024 at 16:32.
Pushed by tfry into branch 'master'.

Fix status display in case of errors

M  +1    -1    rkward/misc/rkxmlguipreviewarea.cpp
M  +5    -4    rkward/windows/rkcommandeditorwindow.cpp

https://invent.kde.org/education/rkward/-/commit/74038c419cad02c691ef408e46f38f4161701bc1

diff --git a/rkward/misc/rkxmlguipreviewarea.cpp b/rkward/misc/rkxmlguipreviewarea.cpp
index ad03db4c7..ec451db9b 100644
--- a/rkward/misc/rkxmlguipreviewarea.cpp
+++ b/rkward/misc/rkxmlguipreviewarea.cpp
@@ -286,8 +286,8 @@ void RKPreviewManager::previewCommandDone (RCommand* command) {
 	} else {
 		QString warnings = command->warnings() + command->error();
 		if (!warnings.isEmpty()) warnings = QString("<b>%1</b>\n<pre>%2</pre>").arg(i18n("Warnings or Errors:"), warnings.toHtmlEscaped());
-		updateStatusDisplay(warnings);
 		current_preview_failed = command->failed();
+		updateStatusDisplay(warnings);
 	}
 }
 
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index c627512ad..e96ce0a3f 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -625,7 +625,7 @@ QString RmarkDownRender(const QString &infile, const QString &outdir, const QStr
 	".check.for.software <- function(command, message) {\n"
 	"	output <- ''\n"
 	"	for (i in 1:length(command)) {\n"
-	"		if (!nzchar(Sys.which(command[i]))) output <- paste0(output, '<h2>%1</h2><p>', message[i], '</p>\n')\n"
+	"		if (!nzchar(Sys.which(command[i]))) output <- paste0(output, '<h2>', %1, '</h2><p>', message[i], '</p>\n')\n"
 	"	}\n"
 	"	output\n"
 	"}\n"
@@ -635,7 +635,7 @@ QString RmarkDownRender(const QString &infile, const QString &outdir, const QStr
 	"})\n"
 	"if (inherits(res, 'try-error')) {\n"
 	"	msg <- attr(res, 'condition')$message\n"
-	"	out <- '<h1>%2</h1>'\n"
+	"	out <- paste0('<h1>', %2, '</h1>')\n"
 	"	if (length(grep('pandoc', msg))) {\n"
 	"		out <- paste0(out, .check.for.software('pandoc', %3))\n"
 	"	}\n"
@@ -643,6 +643,7 @@ QString RmarkDownRender(const QString &infile, const QString &outdir, const QStr
 	"		out <- paste0(out, .check.for.software('pdflatex', %4))\n"
 	"	}\n"
 	"	rk.show.html(content=out)\n"
+	"	stop('%2')\n" // make sure, the status display sees this as an error
 	"} else {\n"
 	"	if (endsWith(toupper(res), '.PDF')) {\n"
 	"		rk.show.pdf(res)\n"
@@ -652,8 +653,8 @@ QString RmarkDownRender(const QString &infile, const QString &outdir, const QStr
 	"		rk.show.html(content=paste0(%5, '<p><a href=\"', res, '\">', res, '</a></p>'))\n"
 	"	}\n"
 	"}\n").arg(
-		i18nc("Caption: Some software is missing.", "Missing software"),
-		i18n("Rendering the preview failed"),
+		RObject::rQuote(i18nc("Caption: Some software is missing.", "Missing software")),
+		RObject::rQuote(i18n("Rendering the preview failed")),
 		RObject::rQuote(i18n("The software <tt>pandoc</tt>, required to rendering R markdown files, is not installed, or not in the system path of the running "
 		"R session. You will need to install pandoc from <a href=\"https://pandoc.org/\">https://pandoc.org/</a>.</br>If it is installed, but cannot be found, "
 		"try adding it to the system path of the running R session at <a href=\"rkward://settings/rbackend\">Settings->Configure RKward->R-backend</a>.")),



More information about the rkward-tracker mailing list