diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-11-12 00:55:34 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-11-12 00:55:34 (GMT) |
commit | 4912e1947c15a8694a89719989e5beb56fa7fed8 (patch) | |
tree | 48dff91672aebac1ef293b583a032678f2e2bc74 /src/declarative/graphicsitems | |
parent | d1d900561a9a51bd44707546e691b013341e221c (diff) | |
download | Qt-4912e1947c15a8694a89719989e5beb56fa7fed8.zip Qt-4912e1947c15a8694a89719989e5beb56fa7fed8.tar.gz Qt-4912e1947c15a8694a89719989e5beb56fa7fed8.tar.bz2 |
Visual tests for positioners
dynamic.qml covers some of the more complex memory management issues,
one of which is also fixed in this commit.
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicspositioners.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index ced9d55..65e63eb 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -70,15 +70,18 @@ void QmlGraphicsBasePositionerPrivate::watchChanges(QmlGraphicsItem *other) void QmlGraphicsBasePositionerPrivate::unwatchChanges(QmlGraphicsItem* other) { Q_Q(QmlGraphicsBasePositioner); - QObject::disconnect(other, SIGNAL(visibleChanged()), + bool stillAlive = false; //Use the return from disconnect to see if it was deleted or just reparented + stillAlive |= QObject::disconnect(other, SIGNAL(visibleChanged()), q, SLOT(prePositioning())); - QObject::disconnect(other, SIGNAL(opacityChanged()), + stillAlive |= QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(prePositioning())); - QObject::disconnect(other, SIGNAL(heightChanged()), + stillAlive |= QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(prePositioning())); - QObject::disconnect(other, SIGNAL(widthChanged()), + stillAlive |= QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(prePositioning())); - static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other))->unregisterSiblingOrderNotification(this); + if(stillAlive) + static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other)) + ->unregisterSiblingOrderNotification(this); watched.removeAll(other); } @@ -266,18 +269,9 @@ void QmlGraphicsBasePositioner::prePositioning() positionedItems << child; } QSet<QmlGraphicsItem *> deletedItems = d->_items - allItems; - foreach(QmlGraphicsItem *child, d->_items){ - if (!allItems.contains(child)){ - if (!deletedItems.contains(child)) { - QObject::disconnect(child, SIGNAL(opacityChanged()), - this, SLOT(prePositioning())); - QObject::disconnect(child, SIGNAL(heightChanged()), - this, SLOT(prePositioning())); - QObject::disconnect(child, SIGNAL(widthChanged()), - this, SLOT(prePositioning())); - } - d->_items -= child; - } + foreach(QmlGraphicsItem *child, deletedItems){ + d->unwatchChanges(child); + d->_items -= child; } d->_animated.clear(); doPositioning(); |