[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
This commit is contained in:
Vlad Zagorodniy 2019-03-11 09:23:24 +02:00
parent a9e469bf13
commit 38e22ce6d1
2 changed files with 12 additions and 2 deletions

View file

@ -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()
{

View file

@ -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;