[globalaccel] Ensure we don't call into deleted InputRedirection on shutdown
KGlobalAccel plugin gets deleted by a global static. At that point InputRedirection is already deleted but the plugin holds a static pointer to it. This change connects to the deleted signal by InputRedirection and ensures that the plugin doesn't call into the deleted code any more.
This commit is contained in:
parent
83cc5f5842
commit
be7e9249cf
2 changed files with 9 additions and 0 deletions
|
@ -38,9 +38,16 @@ bool KGlobalAccelImpl::grabKey(int key, bool grab)
|
||||||
|
|
||||||
void KGlobalAccelImpl::setEnabled(bool enabled)
|
void KGlobalAccelImpl::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
|
if (m_shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
static KWin::InputRedirection *s_input = KWin::InputRedirection::self();
|
static KWin::InputRedirection *s_input = KWin::InputRedirection::self();
|
||||||
if (!s_input) {
|
if (!s_input) {
|
||||||
qFatal("This plugin is intended to be used with KWin and this is not KWin, exiting now");
|
qFatal("This plugin is intended to be used with KWin and this is not KWin, exiting now");
|
||||||
|
} else {
|
||||||
|
if (!m_inputDestroyedConnection) {
|
||||||
|
m_inputDestroyedConnection = connect(s_input, &QObject::destroyed, this, [this] { m_shuttingDown = true; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s_input->registerGlobalAccel(enabled ? this : nullptr);
|
s_input->registerGlobalAccel(enabled ? this : nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ public Q_SLOTS:
|
||||||
bool checkKeyPressed(int keyQt);
|
bool checkKeyPressed(int keyQt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_shuttingDown = false;
|
||||||
|
QMetaObject::Connection m_inputDestroyedConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue