[aurorae] Fix crash on KCM teardown with Qt5.14
Summary: Context behaviour subtly changed in Qt5.14 which has exposed some questionable things in this KCM. Auorae::Decoration is a context property of the loaded QML. QObject::~QObject signals it's own deletion before deleting children. This means the bindings of loaded QML update in particular aurorae.qml DecorationOptions { id: options deco: decoration } DecorationOptions has a pointer to the previously set decoration which is now dangling, and we crash. Rather than adding more guards and smart pointers in DecorationOptions, this patch deletes the QQmlContext before deleting the context properties that we expose. It also moves unreferring the shared qmlcontext we inherit from till after we've deleted the child context, because it didn't make sense. Test Plan: Opened KCM Closed the KCM didn't crash Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D24594
This commit is contained in:
parent
82f4e03d7a
commit
446e23af5a
2 changed files with 13 additions and 9 deletions
|
@ -266,17 +266,19 @@ Decoration::Decoration(QObject *parent, const QVariantList &args)
|
|||
|
||||
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()
|
||||
|
@ -285,9 +287,9 @@ void 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 @@ void Decoration::init()
|
|||
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 @@ void Decoration::init()
|
|||
}
|
||||
return;
|
||||
}
|
||||
m_item->setParent(this);
|
||||
m_item->setParent(m_qmlContext);
|
||||
|
||||
QVariant visualParent = property("visualParent");
|
||||
if (visualParent.isValid()) {
|
||||
|
|
|
@ -27,6 +27,7 @@ class QOffscreenSurface;
|
|||
class QOpenGLContext;
|
||||
class QOpenGLFramebufferObject;
|
||||
class QQmlComponent;
|
||||
class QQmlContext;
|
||||
class QQmlEngine;
|
||||
class QQuickItem;
|
||||
class QQuickRenderControl;
|
||||
|
@ -82,7 +83,8 @@ private:
|
|||
QImage m_buffer;
|
||||
QRect m_contentRect; //the geometry of the part of the buffer that is not a shadow when buffer was created.
|
||||
QPointer<QQuickWindow> 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;
|
||||
|
|
Loading…
Reference in a new issue