Ignore parent scopes that are in the process of being removed

Summary:
When we destroy a colorscope, all children will try to reparent. This patch
makes it so they never pick an object if it's being removed.

Test Plan:
The logout screen greeter and kscreenlocker doesn't crash anymore
upon close.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D25953
This commit is contained in:
Aleix Pol 2019-12-13 15:35:29 +01:00
parent c33fcaa8d7
commit 208b94365c
2 changed files with 3 additions and 2 deletions

View File

@ -70,6 +70,7 @@ ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject)
ColorScope::~ColorScope()
{
m_deleting = true;
s_attachedScopes.remove(m_parent);
}
@ -127,8 +128,7 @@ ColorScope *ColorScope::findParentScope()
// Make sure AppletInterface always has a ColorScope
s = static_cast<ColorScope *>(qmlAttachedPropertiesObject<ColorScope>(candidate, qobject_cast<PlasmaQuick::AppletQuickItem *>(candidate)));
}
if (s) {
if (s && !s->m_deleting) {
setParentScope(s);
return s;
}

View File

@ -133,6 +133,7 @@ private:
QPointer<ColorScope> m_parentScope;
QObject *const m_parent;
Plasma::Theme::ColorGroup m_actualGroup;
bool m_deleting = false;
static QHash<QObject *, ColorScope *> s_attachedScopes;