9da807d
From 2f7c659b2c82ea10017879ea5ac44a6c5c60505c Mon Sep 17 00:00:00 2001
b0486fb
From: Fushan Wen <qydwhotmail@gmail.com>
b0486fb
Date: Fri, 21 Apr 2023 23:38:04 +0800
9da807d
Subject: [PATCH 22/31] Revert "QQuickItem: Fix effective visibility for items
b0486fb
 without parent"
b0486fb
b0486fb
This breaks applications that use QQmlPropertyList to store QQuickItem
b0486fb
and don't set a parentItem for them.
b0486fb
b0486fb
Ref: https://github.com/musescore/MuseScore/issues/17276
b0486fb
b0486fb
This reverts commit 45c22a0221937682f4496801a495458a00f76d3a.
b0486fb
---
b0486fb
 src/quick/items/qquickitem.cpp                 | 6 ++++--
b0486fb
 tests/auto/quick/qquickitem/tst_qquickitem.cpp | 2 --
b0486fb
 2 files changed, 4 insertions(+), 4 deletions(-)
b0486fb
b0486fb
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
b0486fb
index 0d421349d7..c370d6e5c3 100644
b0486fb
--- a/src/quick/items/qquickitem.cpp
b0486fb
+++ b/src/quick/items/qquickitem.cpp
b0486fb
@@ -6081,8 +6081,10 @@ void QQuickItem::setEnabled(bool e)
b0486fb
 
b0486fb
 bool QQuickItemPrivate::calcEffectiveVisible() const
b0486fb
 {
b0486fb
-    // An item is visible if it is a child of a visible parent, and not explicitly hidden.
b0486fb
-    return explicitVisible && parentItem && QQuickItemPrivate::get(parentItem)->effectiveVisible;
b0486fb
+    // XXX todo - Should the effective visible of an element with no parent just be the current
b0486fb
+    // effective visible?  This would prevent pointless re-processing in the case of an element
b0486fb
+    // moving to/from a no-parent situation, but it is different from what graphics view does.
b0486fb
+    return explicitVisible && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveVisible);
b0486fb
 }
b0486fb
 
b0486fb
 bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
b0486fb
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
b0486fb
index 34eefd85e6..42348d8dd1 100644
b0486fb
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
b0486fb
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
b0486fb
@@ -989,9 +989,7 @@ void tst_qquickitem::setParentItem()
b0486fb
 
b0486fb
 void tst_qquickitem::visible()
b0486fb
 {
b0486fb
-    QQuickWindow window;
b0486fb
     QQuickItem *root = new QQuickItem;
b0486fb
-    root->setParentItem(window.contentItem());
b0486fb
 
b0486fb
     QQuickItem *child1 = new QQuickItem;
b0486fb
     child1->setParentItem(root);
b0486fb
-- 
9da807d
2.43.0
b0486fb