summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2010-09-30 15:23:27 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-10-01 05:36:09 (GMT)
commit0d31b86d1fd0fdbcc95c80ce91f505a2c8b0bc26 (patch)
treebffb5eaa5267cc6167bdb85dd5fec930d98e117a /src/declarative
parent39f6657f74d78e5b856121310cf060a02bc1c352 (diff)
downloadQt-0d31b86d1fd0fdbcc95c80ce91f505a2c8b0bc26.zip
Qt-0d31b86d1fd0fdbcc95c80ce91f505a2c8b0bc26.tar.gz
Qt-0d31b86d1fd0fdbcc95c80ce91f505a2c8b0bc26.tar.bz2
Use setParentItem() instead of setParentItemHelper if componentComplete is true
This ensures that if the component has already been completed, itemChange() is called. This is required to modify QDeclarativePositions in the visual editor, while keeping a legal state. Without this patch notifications are missing and the Positioner keeps track of already deleted children. This resulted in a crash. Reviewed-by: Thomas Hartmann (cherry picked from commit 1f8bb573f06234a3d13fb57de5eb644824d5024f)
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp24
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp19
2 files changed, 34 insertions, 9 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 84b0ccf..29879fe 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1046,10 +1046,16 @@ void QDeclarativeFlickable::cancelFlick()
void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o);
- if (i)
- i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
- else
+ if (i) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(i);
+ if (static_cast<QDeclarativeItemPrivate*>(d)->componentComplete) {
+ i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
+ } else {
+ d->setParentItemHelper(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem, 0, 0);
+ }
+ } else {
o->setParent(prop->object);
+ }
}
static inline int children_count_helper(QGraphicsObject *object)
@@ -1071,8 +1077,16 @@ static inline void children_clear_helper(QGraphicsObject *object)
{
QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(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 (static_cast<QDeclarativeItemPrivate*>(d)->componentComplete) {
+ 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, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+ }
+ }
+
}
int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *prop)
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 3c2f0a8..830f8e3 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1614,7 +1614,13 @@ void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *pro
while (mo && mo != &QGraphicsObject::staticMetaObject) mo = mo->d.superdata;
if (mo) {
- QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(o))->setParentItemHelper(that, 0, 0);
+ QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(o);
+ QDeclarativeItemPrivate *contentItemPrivate = static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(graphicsObject));
+ if (contentItemPrivate->componentComplete) {
+ graphicsObject->setParentItem(that);
+ } else {
+ contentItemPrivate->setParentItemHelper(that, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+ }
} else {
o->setParent(that);
}
@@ -1637,10 +1643,15 @@ static inline QObject *children_at_helper(QDeclarativeListProperty<QObject> *pro
static inline void children_clear_helper(QDeclarativeListProperty<QObject> *prop)
{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(prop->object));
+ QDeclarativeItemPrivate *d = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(prop->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->componentComplete) {
+ 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, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+ }
}
int QDeclarativeItemPrivate::data_count(QDeclarativeListProperty<QObject> *prop)