[education/rkward] rkward/windows: Properly separate shared and per-instance data

Thomas Friedrichsmeier null at kde.org
Mon Jan 12 19:55:45 GMT 2026


Git commit 513fe2eb5ee03b44e924cc2108c95f18cd9337c4 by Thomas Friedrichsmeier.
Committed on 12/01/2026 at 19:55.
Pushed by tfry into branch 'master'.

Properly separate shared and per-instance data

M  +2    -1    rkward/windows/rkcommandeditorwindow.cpp
M  +1    -1    rkward/windows/rkcommandeditorwindow.h

https://invent.kde.org/education/rkward/-/commit/513fe2eb5ee03b44e924cc2108c95f18cd9337c4

diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 71d639316..3367e8411 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -588,6 +588,7 @@ void RKCommandEditorWindow::initializeActions(KActionCollection *ac) {
 	action_preview_as_you_type->setToolTip(i18n("When this option is enabled, an update of the preview will be triggered every time you modify the script. When this option is disabled, the preview will be updated whenever you save the script, only."));
 	action_preview_as_you_type->setChecked(m_doc->url().isEmpty()); // By default, update as you type for unsaved "quick and dirty" scripts, preview on save for saved scripts
 	initPreviewModes();
+	active_mode = nullptr; // no_preview
 	actionmenu_preview->addAction(new RKPreviewModeSelector(this));
 	actionmenu_preview->addAction(action_preview_as_you_type);
 	ac->addAction(QStringLiteral("render_preview"), actionmenu_preview);
@@ -776,6 +777,7 @@ void RKCommandEditorWindow::discardPreview() {
 	}
 }
 
+// static
 void RKCommandEditorWindow::initPreviewModes() {
 	if (!preview_modes.isEmpty()) return;
 	RK_TRACE(COMMANDEDITOR);
@@ -795,7 +797,6 @@ void RKCommandEditorWindow::initPreviewModes() {
 	no_preview->validator = [](KTextEditor::Document *) -> bool {
 		return true;
 	};
-	active_mode = no_preview;
 	preview_modes.append(no_preview);
 
 	auto markdown = new RKPreviewMode(i18n("R Markdown"), QIcon::fromTheme(u"preview_math"_s), u".Rmd"_s);
diff --git a/rkward/windows/rkcommandeditorwindow.h b/rkward/windows/rkcommandeditorwindow.h
index 1a92ac21a..47384384d 100644
--- a/rkward/windows/rkcommandeditorwindow.h
+++ b/rkward/windows/rkcommandeditorwindow.h
@@ -199,7 +199,7 @@ class RKCommandEditorWindow : public RKMDIWindow, public RKScriptContextProvider
 	QString _id;
 	static QMap<QString, KTextEditor::Document *> unnamed_documents;
 
-	void initPreviewModes();
+	static void initPreviewModes();
 	/** call doRenderPreview, but debounced */
 	void triggerPreview(int timeout = 0);
 	RKPreviewMode *active_mode;



More information about the rkward-tracker mailing list