[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.
This commit is contained in:
Martin Gräßlin 2015-11-12 11:29:56 +01:00
parent 7b459214d9
commit c1e9280efa
4 changed files with 17 additions and 1 deletions

View file

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "kwin_wayland_test.h" #include "kwin_wayland_test.h"
#include "../../abstract_backend.h" #include "../../abstract_backend.h"
#include "../../effects.h"
#include "../../wayland_server.h" #include "../../wayland_server.h"
#include "../../workspace.h" #include "../../workspace.h"
#include "../../xcbutils.h" #include "../../xcbutils.h"
@ -52,6 +53,10 @@ WaylandTestApplication::~WaylandTestApplication()
{ {
destroyWorkspace(); destroyWorkspace();
waylandServer()->dispatch(); waylandServer()->dispatch();
// need to unload all effects prior to destroying X connection as they might do X calls
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
}
if (x11Connection()) { if (x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
destroyAtoms(); destroyAtoms();

View file

@ -315,6 +315,11 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
} }
EffectsHandlerImpl::~EffectsHandlerImpl() EffectsHandlerImpl::~EffectsHandlerImpl()
{
unloadAllEffects();
}
void EffectsHandlerImpl::unloadAllEffects()
{ {
makeOpenGLContextCurrent(); makeOpenGLContextCurrent();
if (keyboard_grab_effect != NULL) if (keyboard_grab_effect != NULL)

View file

@ -62,7 +62,7 @@ class EffectLoader;
class Unmanaged; class Unmanaged;
class ScreenLockerWatcher; class ScreenLockerWatcher;
class EffectsHandlerImpl : public EffectsHandler class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler
{ {
Q_OBJECT Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects") Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects")
@ -206,6 +206,7 @@ public:
void reloadEffect(Effect *effect) override; void reloadEffect(Effect *effect) override;
QStringList loadedEffects() const; QStringList loadedEffects() const;
QStringList listOfEffects() const; QStringList listOfEffects() const;
void unloadAllEffects();
QList<EffectWindow*> elevatedWindows() const; QList<EffectWindow*> elevatedWindows() const;
QStringList activeEffects() const; QStringList activeEffects() const;

View file

@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <config-kwin.h> #include <config-kwin.h>
// kwin // kwin
#include "abstract_backend.h" #include "abstract_backend.h"
#include "effects.h"
#include "wayland_server.h" #include "wayland_server.h"
#include "xcbutils.h" #include "xcbutils.h"
@ -76,6 +77,10 @@ ApplicationWayland::~ApplicationWayland()
{ {
destroyWorkspace(); destroyWorkspace();
waylandServer()->dispatch(); waylandServer()->dispatch();
// need to unload all effects prior to destroying X connection as they might do X calls
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
}
if (x11Connection()) { if (x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
destroyAtoms(); destroyAtoms();