From c2e0c13b7b55166714d67533fd2073fcb893bfa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 19 Aug 2013 12:15:42 +0200 Subject: [PATCH] Delay performWindowOperation to next event cycle in UserActionsMenu In case that the window operation results in destroying the window decoration we need to have the menu closed before the deco gets destroyed. Otherwise Qt crashes. --- libkdecorations/kdecoration.h | 1 + useractions.cpp | 8 +++++++- workspace.h | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libkdecorations/kdecoration.h b/libkdecorations/kdecoration.h index 0a20145e53..fb40259e23 100644 --- a/libkdecorations/kdecoration.h +++ b/libkdecorations/kdecoration.h @@ -1219,5 +1219,6 @@ inline int KDecoration::height() const /** @} */ Q_DECLARE_OPERATORS_FOR_FLAGS(KDecoration::QuickTileMode) +Q_DECLARE_METATYPE(KDecorationDefines::WindowOperation) #endif diff --git a/useractions.cpp b/useractions.cpp index 232d301b52..afb6c74a03 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -770,7 +770,13 @@ void UserActionsMenu::slotWindowOperation(QAction *action) }; if (!type.isEmpty()) helperDialog(type, c); - Workspace::self()->performWindowOperation(c.data(), op); + // need to delay performing the window operation as we need to have the + // user actions menu closed before we destroy the decoration. Otherwise Qt crashes + qRegisterMetaType(); + QMetaObject::invokeMethod(workspace(), "performWindowOperation", + Qt::QueuedConnection, + Q_ARG(KWin::Client*, c.data()), + Q_ARG(KDecorationDefines::WindowOperation, op)); } void UserActionsMenu::slotSendToDesktop(QAction *action) diff --git a/workspace.h b/workspace.h index 6b67070506..b4d4a098c1 100644 --- a/workspace.h +++ b/workspace.h @@ -233,8 +233,6 @@ public: void updateOnAllDesktopsOfTransients(Client*); void checkTransients(xcb_window_t w); - void performWindowOperation(Client* c, WindowOperation op); - void storeSession(KConfig* config, SMSavePhase phase); void storeClient(KConfigGroup &cg, int num, Client *c); void storeSubSession(const QString &name, QSet sessionIds); @@ -302,6 +300,7 @@ public: bool compositing() const; public Q_SLOTS: + void performWindowOperation(KWin::Client* c, KDecorationDefines::WindowOperation op); // Keybindings //void slotSwitchToWindow( int ); void slotWindowToDesktop();