diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-31 01:01:32 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-31 09:44:09 +0100 |
commit | 9c050d452961f348c8bcc33e3422aed6316bb18b (patch) | |
tree | b8af41758d885bfad84ccbd52e24eb1544908fda /src/quick/items/qquickitem.cpp | |
parent | 59760e6ce0da6780fcbdf0b2dc123f989baaa3eb (diff) | |
parent | bcbc3c9cec1f7d7bb8c9d5f5ea94eb5c81ec2853 (diff) |
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
.qmake.conf
src/qml/common/qv4compileddata_p.h
src/qml/types/qqmlbind.cpp
tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
Change-Id: I6a137907e63445f17a3d6181b832a6bd76135bb2
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index c6a19219ff..0e035af9a6 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2748,22 +2748,35 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) } QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : nullptr; + bool alreadyAddedChild = false; if (d->window == parentWindow) { // Avoid freeing and reallocating resources if the window stays the same. d->parentItem = parentItem; } else { - if (d->window) - d->derefWindow(); + auto oldParentItem = d->parentItem; d->parentItem = parentItem; + if (d->parentItem) { + QQuickItemPrivate::get(d->parentItem)->addChild(this); + alreadyAddedChild = true; + } + if (d->window) { + d->derefWindow(); + // as we potentially changed d->parentWindow above + // the check in derefWindow could not work + // thus, we redo it here with the old parent + if (!oldParentItem) { + QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this); + } + } if (parentWindow) d->refWindow(parentWindow); } d->dirty(QQuickItemPrivate::ParentChanged); - if (d->parentItem) + if (d->parentItem && !alreadyAddedChild) QQuickItemPrivate::get(d->parentItem)->addChild(this); - else if (d->window) + else if (d->window && !alreadyAddedChild) QQuickWindowPrivate::get(d->window)->parentlessItems.insert(this); d->setEffectiveVisibleRecur(d->calcEffectiveVisible()); |