diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2015-03-06 11:39:49 +0100 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2015-03-06 10:56:13 +0000 |
commit | 646e832699d04202804d548991f931a0310ec32b (patch) | |
tree | 08639bf667197671ad0c130323a35bdd416a1132 | |
parent | 65516b7f6cebcbce0db475d08f00f432b0f90c3b (diff) |
Make sure we deref an item from its window.
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>
-rw-r--r-- | src/quick/items/qquickitem.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index d1369fb3ff..a37cc34427 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2527,13 +2527,12 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) 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) |