We should compare against our own window, not our parent's.
The ref/deref logic for items is there to aid us with having "property
var foo: Image { }" in ShaderEffects, where the property is a
parentless member of a given window. The shader effect would ref
all member properties which are used as samplers, giving these items
the same d->window as itself.
As a consequence, it is wrong to check the old parent's window when it
is the item itself that knows which window it is attached to.
Change-Id: Ic34354fd86b52a7334f9757bf408bef0e25ecfd5
Task-number: QTBUG-43376
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
}
- QQuickWindow *oldParentWindow = oldParentItem ? QQuickItemPrivate::get(oldParentItem)->window : 0;
QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : 0;
- if (oldParentWindow == parentWindow) {
+ if (d->window == parentWindow) {
// Avoid freeing and reallocating resources if the window stays the same.
d->parentItem = parentItem;
} else {
- if (oldParentWindow)
+ if (d->window)
d->derefWindow();
d->parentItem = parentItem;
if (parentWindow)