diff --git a/qt5/style/qtcurve_plugin.h b/qt5/style/qtcurve_plugin.h --- a/qt5/style/qtcurve_plugin.h +++ b/qt5/style/qtcurve_plugin.h @@ -34,6 +34,7 @@ ~StylePlugin(); private: void init(); + bool m_eventNotifyCallbackInstalled = false; std::once_flag m_ref_flag; }; diff --git a/qt5/style/qtcurve_plugin.cpp b/qt5/style/qtcurve_plugin.cpp --- a/qt5/style/qtcurve_plugin.cpp +++ b/qt5/style/qtcurve_plugin.cpp @@ -165,16 +165,19 @@ StylePlugin::~StylePlugin() { runAllCleanups(); - QInternal::unregisterCallback(QInternal::EventNotifyCallback, - qtcEventCallback); + if (m_eventNotifyCallbackInstalled) { + QInternal::unregisterCallback(QInternal::EventNotifyCallback, + qtcEventCallback); + } } void StylePlugin::init() { - std::call_once(m_ref_flag, [] { + std::call_once(m_ref_flag, [this] { QInternal::registerCallback(QInternal::EventNotifyCallback, qtcEventCallback); + m_eventNotifyCallbackInstalled = true; #ifdef QTC_QT5_ENABLE_QTQUICK2 QQuickWindow::setDefaultAlphaBuffer(true); #endif