[rkward] /: Fix crash when mousing over code-preview-window with focus-follows-mouse enabled.

Thomas Friedrichsmeier null at kde.org
Sun Apr 26 15:18:45 BST 2020


Git commit f32b83b3cb8a1f9913175f8793ad93321cecd888 by Thomas Friedrichsmeier.
Committed on 26/04/2020 at 14:18.
Pushed by tfry into branch 'master'.

Fix crash when mousing over code-preview-window with focus-follows-mouse enabled.

BUG: 420588

M  +1    -0    ChangeLog
M  +2    -0    rkward/misc/rkxmlguipreviewarea.cpp
M  +6    -0    rkward/windows/rkworkplace.cpp
M  +4    -0    rkward/windows/rkworkplace.h

https://commits.kde.org/rkward/f32b83b3cb8a1f9913175f8793ad93321cecd888

diff --git a/ChangeLog b/ChangeLog
index 5b9e1ebb..0523f960 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 --- Version 0.7.2 - UNRELEASED
+- Fixed: Crash when mousing over code preview window with focus-follows-mouse enabled
 - Add menu action to open any supported file type, directly
 - Support using QWebEngine instead of QtWebKit (still supported)
   - TODO:
diff --git a/rkward/misc/rkxmlguipreviewarea.cpp b/rkward/misc/rkxmlguipreviewarea.cpp
index 3f2dddbe..9837c12d 100644
--- a/rkward/misc/rkxmlguipreviewarea.cpp
+++ b/rkward/misc/rkxmlguipreviewarea.cpp
@@ -30,6 +30,7 @@
 #include <KLocalizedString>
 
 #include "../windows/rkmdiwindow.h"
+#include "../windows/rkworkplace.h"
 #include "../rbackend/rcommand.h"
 #include "../rbackend/rkrinterface.h"
 #include "../rkglobals.h"
@@ -128,6 +129,7 @@ void RKXMLGUIPreviewArea::childEvent (QChildEvent *event) {
 			// avoid shortcut conflicts
 			QList<QAction*> acts = actions ();
 			for (int i = 0; i < acts.size (); ++i) acts[i]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+			RKWorkplace::mainWorkplace()->setWindowNotManaged(child);
 		}
 	}
 	QObject::childEvent (event);
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index 8a4cd8ab..46a66535 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -236,6 +236,12 @@ void RKWorkplace::detachWindow (RKMDIWindow *window, bool was_attached) {
 	if (!was_attached) window->activate ();
 }
 
+void RKWorkplace::setWindowNotManaged(RKMDIWindow* window) {
+	RK_TRACE (APP);
+	RK_ASSERT(window->state == RKMDIWindow::Attached);
+	window->state = RKMDIWindow::Detached;
+}
+
 void RKWorkplace::addWindow (RKMDIWindow *window, bool attached) {
 	RK_TRACE (APP);
 
diff --git a/rkward/windows/rkworkplace.h b/rkward/windows/rkworkplace.h
index 3efc63e3..30cdfa20 100644
--- a/rkward/windows/rkworkplace.h
+++ b/rkward/windows/rkworkplace.h
@@ -207,6 +207,10 @@ Has no effect, if RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsMod
 
 /** For window splitting: Copy the given window (or, if that is not possible, create a placeholder window), and attach it to the main view. */
 	void splitAndAttachWindow (RKMDIWindow *source);
+
+/** Inform the workplace that this window is handled outside the regular attached/detached mechanisms (such as preview windows). Internally, this just sets the window to detached, without giving it a DetachedWindowContainer.
+This seems good enough for now, but may be something to revisit in case of unexpected problems. */
+	void setWindowNotManaged(RKMDIWindow *window);
 signals:
 /** emitted when the workspace Url has changed */
 	void workspaceUrlChanged (const QUrl &url);



More information about the rkward-tracker mailing list