diff --git a/plugins/kglobalaccel/kglobalaccel_plugin.cpp b/plugins/kglobalaccel/kglobalaccel_plugin.cpp index 7aa9c0ff7a..0466f6180e 100644 --- a/plugins/kglobalaccel/kglobalaccel_plugin.cpp +++ b/plugins/kglobalaccel/kglobalaccel_plugin.cpp @@ -38,9 +38,16 @@ bool KGlobalAccelImpl::grabKey(int key, bool grab) void KGlobalAccelImpl::setEnabled(bool enabled) { + if (m_shuttingDown) { + return; + } static KWin::InputRedirection *s_input = KWin::InputRedirection::self(); if (!s_input) { 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); } diff --git a/plugins/kglobalaccel/kglobalaccel_plugin.h b/plugins/kglobalaccel/kglobalaccel_plugin.h index 7ecf2a8d99..4985a9076a 100644 --- a/plugins/kglobalaccel/kglobalaccel_plugin.h +++ b/plugins/kglobalaccel/kglobalaccel_plugin.h @@ -41,6 +41,8 @@ public Q_SLOTS: bool checkKeyPressed(int keyQt); private: + bool m_shuttingDown = false; + QMetaObject::Connection m_inputDestroyedConnection; }; #endif