Skip to content

Commit

Permalink
Revert "QQuickItem: Fix effective visibility for items without parent"
Browse files Browse the repository at this point in the history
This breaks applications that use QQmlPropertyList to store QQuickItem
and don't set a parentItem for them.

Ref: musescore/MuseScore#17276

This reverts commit 45c22a0221937682f4496801a495458a00f76d3a.
  • Loading branch information
easyteacher authored and tsdgeos committed Mar 14, 2024
1 parent 58e43f8 commit e07c828
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/quick/items/qquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6081,8 +6081,10 @@ void QQuickItem::setEnabled(bool e)

bool QQuickItemPrivate::calcEffectiveVisible() const
{
// An item is visible if it is a child of a visible parent, and not explicitly hidden.
return explicitVisible && parentItem && QQuickItemPrivate::get(parentItem)->effectiveVisible;
// XXX todo - Should the effective visible of an element with no parent just be the current
// effective visible? This would prevent pointless re-processing in the case of an element
// moving to/from a no-parent situation, but it is different from what graphics view does.
return explicitVisible && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveVisible);
}

bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
Expand Down
2 changes: 0 additions & 2 deletions tests/auto/quick/qquickitem/tst_qquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,7 @@ void tst_qquickitem::setParentItem()

void tst_qquickitem::visible()
{
QQuickWindow window;
QQuickItem *root = new QQuickItem;
root->setParentItem(window.contentItem());

QQuickItem *child1 = new QQuickItem;
child1->setParentItem(root);
Expand Down

0 comments on commit e07c828

Please sign in to comment.