diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-06 06:16:08 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-06 06:16:08 (GMT) |
commit | bf965a3b74a10636a63f72d72ad41e169a9851e3 (patch) | |
tree | bdc89890964200f2f119e3c92177d924939aa180 /src | |
parent | 385799a8269dfb5b48de9e84e52af780fb400272 (diff) | |
download | Qt-bf965a3b74a10636a63f72d72ad41e169a9851e3.zip Qt-bf965a3b74a10636a63f72d72ad41e169a9851e3.tar.gz Qt-bf965a3b74a10636a63f72d72ad41e169a9851e3.tar.bz2 |
Avoid warnings as delegates with bindings to parent are created and destroyed.
Task-number: QTBUG-10359
Diffstat (limited to 'src')
6 files changed, 29 insertions, 9 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 869826c..75b9d3c 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -378,9 +378,11 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex) if (model->completePending()) { // complete listItem->item->setZValue(1); + listItem->item->setParentItem(q->viewport()); model->completeItem(); + } else { + listItem->item->setParentItem(q->viewport()); } - listItem->item->setParentItem(q->viewport()); unrequestedItems.remove(listItem->item); } requestedIndex = -1; diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 0811278..064a33f 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -573,9 +573,11 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) if (model->completePending()) { // complete listItem->item->setZValue(1); + listItem->item->setParentItem(q->viewport()); model->completeItem(); + } else { + listItem->item->setParentItem(q->viewport()); } - listItem->item->setParentItem(q->viewport()); QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); if (sectionCriteria && sectionCriteria->delegate()) { diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index f01d4c2..c6a6b81 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -44,6 +44,7 @@ #include "qdeclarativeitem.h" #include <qdeclarativecontext.h> +#include <qdeclarativecontext_p.h> #include <qdeclarativeengine.h> #include <qdeclarativeexpression.h> #include <qdeclarativepackage_p.h> @@ -963,6 +964,13 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q } if (d->m_cache.releaseItem(obj)) { + // Remove any bindings to avoid warnings due to parent change. + QObjectPrivate *p = QObjectPrivate::get(obj); + Q_ASSERT(p->declarativeData); + QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData); + if (d->ownContext && d->context) + d->context->clearExpressions(); + if (inPackage) { emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj)); } else { diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index ae4223e..b61b8cb 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -528,13 +528,8 @@ void QDeclarativeContextData::invalidate() parent = 0; } -void QDeclarativeContextData::destroy() +void QDeclarativeContextData::clearExpressions() { - if (linkedContext) - linkedContext->destroy(); - - if (engine) invalidate(); - QDeclarativeAbstractExpression *expression = expressions; while (expression) { QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression; @@ -546,6 +541,16 @@ void QDeclarativeContextData::destroy() expression = nextExpression; } expressions = 0; +} + +void QDeclarativeContextData::destroy() +{ + if (linkedContext) + linkedContext->destroy(); + + if (engine) invalidate(); + + clearExpressions(); while (contextObjects) { QDeclarativeData *co = contextObjects; diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index c7fb099..6b6cd0a 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -113,6 +113,7 @@ class QDeclarativeContextData public: QDeclarativeContextData(); QDeclarativeContextData(QDeclarativeContext *); + void clearExpressions(); void destroy(); void invalidate(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index cc6c5fe..9f5cafe 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -329,8 +329,10 @@ void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) QObjectPrivate *p = QObjectPrivate::get(o); Q_ASSERT(p->declarativeData); QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData); - if (d->ownContext) + if (d->ownContext && d->context) { d->context->destroy(); + d->context = 0; + } } void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) |