[education/rkward] /: Make sure all KTextEditor::Views actually have a pointer to the main window.

Thomas Friedrichsmeier null at kde.org
Fri Jul 8 22:03:44 BST 2022


Git commit ba8b886d9d05741b4b1cd85cbf698eb0e78f9e8f by Thomas Friedrichsmeier.
Committed on 08/07/2022 at 21:02.
Pushed by tfry into branch 'master'.

Make sure all KTextEditor::Views actually have a pointer to the main window.

This fixes crashes in the git blame kate plugin.

CCMAIL: stefan_roediger at gmx.de

M  +1    -0    ChangeLog
M  +2    -1    rkward/windows/katepluginintegration.cpp
M  +1    -2    rkward/windows/rkcommandeditorwindow.cpp

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

diff --git a/ChangeLog b/ChangeLog
index 54197873..784529c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Fixed: Crash when using the "Git blame" kate plugin
 - Fixed: Problem installing R support package in some configurations
 - Fixed: Menubar would disapper after opening script editor, in some configurations
 - Fixed: Very long error messages during R markdown preview could cause the preview window to become too wide
diff --git a/rkward/windows/katepluginintegration.cpp b/rkward/windows/katepluginintegration.cpp
index 4f0f82e2..2d2d7a6a 100644
--- a/rkward/windows/katepluginintegration.cpp
+++ b/rkward/windows/katepluginintegration.cpp
@@ -65,13 +65,14 @@ KatePluginIntegrationApp::KatePluginIntegrationApp(QObject *parent) : QObject (p
 
 KatePluginIntegrationApp::~KatePluginIntegrationApp() {
 	RK_TRACE (APP);
+	delete dummy_view; // deletion of view may call into mainwindow, so having this deleted a regular qobject child is too late
 }
 
 KTextEditor::View *KatePluginIntegrationApp::dummyView() {
 	if (!dummy_view) {
 		RK_TRACE (APP);
 		KTextEditor::Document *doc = KTextEditor::Editor::instance()->createDocument (this);
-		dummy_view = doc->createView(0);
+		dummy_view = doc->createView(nullptr, mainWindow()->mainWindow());
 		dummy_view->hide();
 		// Make sure it does not accumulate cruft.
 		connect(doc, &KTextEditor::Document::textChanged, doc, &KTextEditor::Document::clear);
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index d5643ab5..6a5325f8 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -199,7 +199,6 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl &_url,
 	preview = new RKXMLGUIPreviewArea (QString(), this);
 	preview_manager = new RKPreviewManager (this);
 	connect (preview_manager, &RKPreviewManager::statusChanged, this, [this]() { preview_timer.start (500); });
-	m_view = m_doc->createView (this);
 	RKWorkplace::mainWorkplace()->registerNamedWindow (preview_manager->previewId(), this, preview);
 	if (!url.isEmpty ()) {
 		KConfigGroup viewconf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptViewSettings %1").arg (RKWorkplace::mainWorkplace ()->portableUrl (url)));
@@ -306,8 +305,8 @@ RKCommandEditorWindow::~RKCommandEditorWindow () {
 	}
 
 	discardPreview ();
-	delete m_view;
 	m_doc->waitSaveComplete ();
+	delete m_view;
 	QList<KTextEditor::View*> views = m_doc->views ();
 	if (views.isEmpty ()) {
 		if (visible_to_kateplugins) {


More information about the rkward-tracker mailing list