From c1e9280efa56d8c9199801f259717a28dbb9c530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 12 Nov 2015 11:29:56 +0100 Subject: [PATCH] [wayland] Unload all effects prior to destroying Xwayland connection Some effects do X11 calls in their cleanup code through external libraries (e.g. KSelectionOwner). As we cannot control that we need to ensure the effects are unloaded prior to destroying the Xwayland connection. --- autotests/wayland/kwin_wayland_test.cpp | 5 +++++ effects.cpp | 5 +++++ effects.h | 3 ++- main_wayland.cpp | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/autotests/wayland/kwin_wayland_test.cpp b/autotests/wayland/kwin_wayland_test.cpp index ef08c985ff..2c1a01d9ee 100644 --- a/autotests/wayland/kwin_wayland_test.cpp +++ b/autotests/wayland/kwin_wayland_test.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "kwin_wayland_test.h" #include "../../abstract_backend.h" +#include "../../effects.h" #include "../../wayland_server.h" #include "../../workspace.h" #include "../../xcbutils.h" @@ -52,6 +53,10 @@ WaylandTestApplication::~WaylandTestApplication() { destroyWorkspace(); waylandServer()->dispatch(); + // need to unload all effects prior to destroying X connection as they might do X calls + if (effects) { + static_cast(effects)->unloadAllEffects(); + } if (x11Connection()) { Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); destroyAtoms(); diff --git a/effects.cpp b/effects.cpp index 46409e3652..0f0ac4e3a3 100644 --- a/effects.cpp +++ b/effects.cpp @@ -315,6 +315,11 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) } EffectsHandlerImpl::~EffectsHandlerImpl() +{ + unloadAllEffects(); +} + +void EffectsHandlerImpl::unloadAllEffects() { makeOpenGLContextCurrent(); if (keyboard_grab_effect != NULL) diff --git a/effects.h b/effects.h index c2e0221429..1d0652a872 100644 --- a/effects.h +++ b/effects.h @@ -62,7 +62,7 @@ class EffectLoader; class Unmanaged; class ScreenLockerWatcher; -class EffectsHandlerImpl : public EffectsHandler +class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects") @@ -206,6 +206,7 @@ public: void reloadEffect(Effect *effect) override; QStringList loadedEffects() const; QStringList listOfEffects() const; + void unloadAllEffects(); QList elevatedWindows() const; QStringList activeEffects() const; diff --git a/main_wayland.cpp b/main_wayland.cpp index f15601bad7..7c4f8570f4 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -22,6 +22,7 @@ along with this program. If not, see . #include // kwin #include "abstract_backend.h" +#include "effects.h" #include "wayland_server.h" #include "xcbutils.h" @@ -76,6 +77,10 @@ ApplicationWayland::~ApplicationWayland() { destroyWorkspace(); waylandServer()->dispatch(); + // need to unload all effects prior to destroying X connection as they might do X calls + if (effects) { + static_cast(effects)->unloadAllEffects(); + } if (x11Connection()) { Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); destroyAtoms();