summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2010-09-30 14:27:25 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-10-01 05:36:18 (GMT)
commit8ece6273489f8fe032ad3da30468ee65fe55573f (patch)
tree2fdda8cf8a5e2b8357b16845ba304240b6cec9e3
parent0d31b86d1fd0fdbcc95c80ce91f505a2c8b0bc26 (diff)
downloadQt-8ece6273489f8fe032ad3da30468ee65fe55573f.zip
Qt-8ece6273489f8fe032ad3da30468ee65fe55573f.tar.gz
Qt-8ece6273489f8fe032ad3da30468ee65fe55573f.tar.bz2
Add sendParentChangeNotification to QGraphicsItem
Fixes crash in creator. If flag is true notifications are sent. It is important that positioners work correctly and don't leak. Reviewed-By: Alexis Menard (cherry picked from commit 3b43389b78925ce87d660c343c925fa280b91e11)
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp16
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h4
2 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b404692..3b18c31 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -7669,7 +7669,12 @@ void QGraphicsObject::updateMicroFocus()
void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
{
- QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast<QGraphicsObject *>(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+ QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
+ if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
+ item->setParentItem(graphicsObject);
+ } else {
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ }
}
int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list)
@@ -7691,8 +7696,13 @@ void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObje
{
QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
int childCount = d->children.count();
- for (int index = 0; index < childCount; index++)
- QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+ if (d->sendParentChangeNotification) {
+ for (int index = 0; index < childCount; index++)
+ d->children.at(0)->setParentItem(0);
+ } else {
+ for (int index = 0; index < childCount; index++)
+ QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
+ }
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 77e4054..c8a7699 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -238,6 +238,7 @@ public:
pendingPolish(0),
mayHaveChildWithGraphicsEffect(0),
isDeclarativeItem(0),
+ sendParentChangeNotification(0),
globalStackingOrder(-1),
q_ptr(0)
{
@@ -584,7 +585,8 @@ public:
quint32 pendingPolish : 1;
quint32 mayHaveChildWithGraphicsEffect : 1;
quint32 isDeclarativeItem : 1;
- quint32 padding : 23;
+ quint32 sendParentChangeNotification : 1;
+ quint32 padding : 22;
// Optional stacking order
int globalStackingOrder;