keep track of the context parents
keep internally a pointer (important that is *not* a smart pointer) to the item the context has been created for. on context deletion, remove the copy from the static bookeeping hash this solves two related crashes: an infinite recursion and a connection to a deleted object
This commit is contained in:
parent
dc1bfc3de1
commit
5911ad2920
@ -29,7 +29,8 @@ QHash<QObject *, ColorScope *> ColorScope::s_attachedScopes = QHash<QObject *, C
|
|||||||
ColorScope::ColorScope(QQuickItem *parent)
|
ColorScope::ColorScope(QQuickItem *parent)
|
||||||
: QQuickItem(parent),
|
: QQuickItem(parent),
|
||||||
m_inherit(false),
|
m_inherit(false),
|
||||||
m_group(Plasma::Theme::NormalColorGroup)
|
m_group(Plasma::Theme::NormalColorGroup),
|
||||||
|
m_parent(parent)
|
||||||
{
|
{
|
||||||
connect(&m_theme, &Plasma::Theme::themeChanged, this, &ColorScope::colorsChanged);
|
connect(&m_theme, &Plasma::Theme::themeChanged, this, &ColorScope::colorsChanged);
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ ColorScope::ColorScope(QQuickItem *parent)
|
|||||||
|
|
||||||
ColorScope::~ColorScope()
|
ColorScope::~ColorScope()
|
||||||
{
|
{
|
||||||
s_attachedScopes.remove(parentItem());
|
s_attachedScopes.remove(m_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorScope *ColorScope::qmlAttachedProperties(QObject *object)
|
ColorScope *ColorScope::qmlAttachedProperties(QObject *object)
|
||||||
@ -65,11 +66,11 @@ ColorScope *ColorScope::qmlAttachedProperties(QObject *object)
|
|||||||
ColorScope *ColorScope::findParentScope() const
|
ColorScope *ColorScope::findParentScope() const
|
||||||
{
|
{
|
||||||
QQuickItem *p = 0;
|
QQuickItem *p = 0;
|
||||||
if (parentItem()) {
|
if (m_parent) {
|
||||||
p = parentItem()->parentItem();
|
p = m_parent->parentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p || !parentItem()) {
|
if (!p || !m_parent) {
|
||||||
if (m_parentScope) {
|
if (m_parentScope) {
|
||||||
disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged,
|
disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged,
|
||||||
this, &ColorScope::colorGroupChanged);
|
this, &ColorScope::colorGroupChanged);
|
||||||
@ -91,10 +92,12 @@ ColorScope *ColorScope::findParentScope() const
|
|||||||
disconnect(m_parentScope.data(), &ColorScope::colorsChanged,
|
disconnect(m_parentScope.data(), &ColorScope::colorsChanged,
|
||||||
this, &ColorScope::colorsChanged);
|
this, &ColorScope::colorsChanged);
|
||||||
}
|
}
|
||||||
connect(c, &ColorScope::colorGroupChanged,
|
if (c) {
|
||||||
this, &ColorScope::colorGroupChanged);
|
connect(c, &ColorScope::colorGroupChanged,
|
||||||
connect(c, &ColorScope::colorsChanged,
|
this, &ColorScope::colorGroupChanged);
|
||||||
this, &ColorScope::colorsChanged);
|
connect(c, &ColorScope::colorsChanged,
|
||||||
|
this, &ColorScope::colorsChanged);
|
||||||
|
}
|
||||||
//HACK
|
//HACK
|
||||||
const_cast<ColorScope *>(this)->m_parentScope = c;
|
const_cast<ColorScope *>(this)->m_parentScope = c;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ private:
|
|||||||
Plasma::Theme m_theme;
|
Plasma::Theme m_theme;
|
||||||
Plasma::Theme::ColorGroup m_group;
|
Plasma::Theme::ColorGroup m_group;
|
||||||
QPointer<ColorScope> m_parentScope;
|
QPointer<ColorScope> m_parentScope;
|
||||||
|
QQuickItem *m_parent;
|
||||||
|
|
||||||
static QHash<QObject *, ColorScope *> s_attachedScopes;
|
static QHash<QObject *, ColorScope *> s_attachedScopes;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user