From 09e7a5a6bb6a5b56ad3f7028b8d909fb73c05d31 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 29 Nov 2019 13:44:58 +0100 Subject: [PATCH] also monitor window changes fixes some scopes not finding their parent and never getting notified when it changes --- src/declarativeimports/core/colorscope.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 8892d6bca..68e335f8d 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -50,8 +51,17 @@ ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) connect(this, &ColorScope::colorGroupChanged, this, &ColorScope::colorsChanged); if (parentObject && qobject_cast(parentObject)) { + connect(static_cast(parentObject), &QQuickItem::windowChanged, + this, [this, parentObject]() { + findParentScope(); + checkColorGroupChanged(); + }); + connect(static_cast(parentObject), &QQuickItem::parentChanged, - this, &ColorScope::checkColorGroupChanged); + this, [this, parentObject]() { + findParentScope(); + checkColorGroupChanged(); + }); } else if (parent) { connect(parent, &QQuickItem::parentChanged, this, &ColorScope::checkColorGroupChanged); @@ -116,6 +126,7 @@ ColorScope *ColorScope::findParentScope() return s; } } + return nullptr; } @@ -195,6 +206,7 @@ void ColorScope::itemChange(ItemChange change, const ItemChangeData &value) if (change == QQuickItem::ItemSceneChange) { //we have a window: create the representations if needed if (value.window) { + findParentScope(); checkColorGroupChanged(); } }