[education/rkward] rkward/windows: If a .RData-file exists, in the current wd, add it to quick-open links. Also fix crash when loading workspace from welcome page.

Thomas Friedrichsmeier null at kde.org
Sun Apr 24 14:29:55 BST 2022


Git commit 58b9e0a538d6d1bb7c44558c255b088291cf86fb by Thomas Friedrichsmeier.
Committed on 24/04/2022 at 13:29.
Pushed by tfry into branch 'master'.

If a .RData-file exists, in the current wd, add it to quick-open links. Also fix crash when loading workspace from welcome page.

M  +9    -2    rkward/windows/rkhtmlwindow.cpp

https://invent.kde.org/education/rkward/commit/58b9e0a538d6d1bb7c44558c255b088291cf86fb

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 51d56d69..f81920dd 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -590,11 +590,13 @@ bool RKHTMLWindow::handleRKWardURL (const QUrl &url, RKHTMLWindow *window) {
 			if (category == RKRecentUrls::scriptsId()) {
 				RKWardMainWindow::getMain()->slotOpenCommandEditor(target);
 			} else if (category == RKRecentUrls::workspaceId()) {
-				RKWardMainWindow::getMain()->askOpenWorkspace(target);
+				// 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); });
 			} else if (category == RKRecentUrls::outputId()) {
 				RKWardMainWindow::getMain()->slotOpenOutput(target);
 			} else {
-				RKWorkplace::mainWorkplace()->openAnyUrl(target);
+				// See opening workspace, above.
+				QTimer::singleShot(0, [target]() { RKWorkplace::mainWorkplace()->openAnyUrl(target); });
 			}
 		} else if (url.host () == "actions") {  // anything else
 			QString action = url.path ();
@@ -1126,6 +1128,11 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
 				writeHTML("<ul>\n");
 				QString category = help_xml_helper.getStringAttribute(*it, "category", QString(), DL_WARNING);
 				auto list = RKRecentUrls::allRecentUrls(category);
+				if (category == RKRecentUrls::workspaceId()) {
+					if (QFile::exists(".RData")) {
+						list.prepend(QUrl::fromLocalFile(QFileInfo(".RData").absoluteFilePath()));
+					}
+				}
 				for (int i = 0; i < list.size(); ++i) {
 					writeHTML(QString("<li><a href=\"rkward://open/%1/%2\" title=\"%2\">%3</a></li>\n").arg(category, list[i].url(), RKCommonFunctions::escape(list[i].url(QUrl::PreferLocalFile))));
 				}


More information about the rkward-tracker mailing list