summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2010-09-30 15:23:27 (GMT)
committerMarco Bubke <marco.bubke@nokia.com>2010-09-30 15:36:30 (GMT)
commit1f8bb573f06234a3d13fb57de5eb644824d5024f (patch)
tree70ec86c96c1328f5e1729c9021ef07bd5cddeab9 /src
parenta1f050fe4217d3a642ab7f4df8e50c21aa51689c (diff)
downloadQt-1f8bb573f06234a3d13fb57de5eb644824d5024f.zip
Qt-1f8bb573f06234a3d13fb57de5eb644824d5024f.tar.gz
Qt-1f8bb573f06234a3d13fb57de5eb644824d5024f.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
Diffstat (limited to 'src')
-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 f9c16b3..33c21b1 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 484c168..250a43b 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)