From 38e22ce6d18ca3f71cc1b3213ce4fc7de9cc8ef4 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Mon, 11 Mar 2019 09:23:24 +0200 Subject: [PATCH] [platforms/x11] Properly unload effects on X11 Summary: When Compositor finishes compositing, it destroys EffectsHandlerImpl, which in its turn tries to unload all effects. But there is a problem... EffectsHandlerImpl has platform-specific hooks to ungrab keyboard and also stop mouse interception. Given that any call made to a virtual function in the destructor of a base class(EffectsHandlerImpl) won't go to a derived class(EffectsHandlerImplX11), keyboard won't be ungrabbed even if effect that grabbed it is already gone. BUG: 399572 Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19178 --- plugins/platforms/x11/standalone/effects_x11.cpp | 12 +++++++++++- plugins/platforms/x11/standalone/effects_x11.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/platforms/x11/standalone/effects_x11.cpp b/plugins/platforms/x11/standalone/effects_x11.cpp index adb26de433..7a8134824d 100644 --- a/plugins/platforms/x11/standalone/effects_x11.cpp +++ b/plugins/platforms/x11/standalone/effects_x11.cpp @@ -43,7 +43,17 @@ EffectsHandlerImplX11::EffectsHandlerImplX11(Compositor *compositor, Scene *scen ); } -EffectsHandlerImplX11::~EffectsHandlerImplX11() = default; +EffectsHandlerImplX11::~EffectsHandlerImplX11() +{ + // EffectsHandlerImpl tries to unload all effects when it's destroyed. + // The routine that unloads effects makes some calls (indirectly) to + // doUngrabKeyboard and doStopMouseInterception, which are virtual. + // Given that any call to a virtual function in the destructor of a base + // class will never go to a derived class, we have to unload effects + // here. Yeah, this is quite a bit ugly but it's fine; someday, X11 + // will be dead (or not?). + unloadAllEffects(); +} bool EffectsHandlerImplX11::doGrabKeyboard() { diff --git a/plugins/platforms/x11/standalone/effects_x11.h b/plugins/platforms/x11/standalone/effects_x11.h index 738bf55ca4..94c83b221e 100644 --- a/plugins/platforms/x11/standalone/effects_x11.h +++ b/plugins/platforms/x11/standalone/effects_x11.h @@ -35,7 +35,7 @@ class EffectsHandlerImplX11 : public EffectsHandlerImpl Q_OBJECT public: explicit EffectsHandlerImplX11(Compositor *compositor, Scene *scene); - virtual ~EffectsHandlerImplX11(); + ~EffectsHandlerImplX11() override; void defineCursor(Qt::CursorShape shape) override;