diff --git a/plugins/kdecorations/aurorae/src/aurorae.h b/plugins/kdecorations/aurorae/src/aurorae.h --- a/plugins/kdecorations/aurorae/src/aurorae.h +++ b/plugins/kdecorations/aurorae/src/aurorae.h @@ -27,6 +27,7 @@ class QOpenGLContext; class QOpenGLFramebufferObject; class QQmlComponent; +class QQmlContext; class QQmlEngine; class QQuickItem; class QQuickRenderControl; @@ -82,7 +83,8 @@ QImage m_buffer; QRect m_contentRect; //the geometry of the part of the buffer that is not a shadow when buffer was created. QPointer m_view; - QQuickItem *m_item; + QQuickItem *m_item = nullptr; + QQmlContext *m_qmlContext = nullptr; KWin::Borders *m_borders; KWin::Borders *m_maximizedBorders; KWin::Borders *m_extendedBorders; diff --git a/plugins/kdecorations/aurorae/src/aurorae.cpp b/plugins/kdecorations/aurorae/src/aurorae.cpp --- a/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -266,28 +266,30 @@ Decoration::~Decoration() { - Helper::instance().unref(); if (m_context) { m_context->makeCurrent(m_offscreenSurface.data()); delete m_renderControl; delete m_view.data(); m_fbo.reset(); - delete m_item; m_context->doneCurrent(); } + // deleted explicitly before our own qobject destructor as "this" is a context property of m_qmlContext, + // and changing contextProperties is a bad idea + delete m_qmlContext; + Helper::instance().unref(); } void Decoration::init() { KDecoration2::Decoration::init(); auto s = settings(); connect(s.data(), &KDecoration2::DecorationSettings::reconfigured, this, &Decoration::configChanged); - QQmlContext *context = new QQmlContext(Helper::instance().rootContext(), this); - context->setContextProperty(QStringLiteral("decoration"), this); - context->setContextProperty(QStringLiteral("decorationSettings"), s.data()); + m_qmlContext = new QQmlContext(Helper::instance().rootContext(), this); + m_qmlContext->setContextProperty(QStringLiteral("decoration"), this); + m_qmlContext->setContextProperty(QStringLiteral("decorationSettings"), s.data()); auto component = Helper::instance().component(m_themeName); if (!component) { return; @@ -310,9 +312,9 @@ connect(this, &Decoration::configChanged, theme, readButtonSize); readButtonSize(); // m_theme->setTabDragMimeType(tabDragMimeType()); - context->setContextProperty(QStringLiteral("auroraeTheme"), theme); + m_qmlContext->setContextProperty(QStringLiteral("auroraeTheme"), theme); } - m_item = qobject_cast< QQuickItem* >(component->create(context)); + m_item = qobject_cast< QQuickItem* >(component->create(m_qmlContext)); if (!m_item) { if (component->isError()) { const auto errors = component->errors(); @@ -322,7 +324,7 @@ } return; } - m_item->setParent(this); + m_item->setParent(m_qmlContext); QVariant visualParent = property("visualParent"); if (visualParent.isValid()) {