diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-29 08:53:38 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-29 09:05:00 (GMT) |
commit | 4c47079d367d44cf18b91965c351a5e9d834b343 (patch) | |
tree | 82e3ba76500f4d346badd7091d1187114fb4cf93 | |
parent | 20290c189bf00fc457ec7d1f82708a8df83adbc5 (diff) | |
download | Qt-4c47079d367d44cf18b91965c351a5e9d834b343.zip Qt-4c47079d367d44cf18b91965c351a5e9d834b343.tar.gz Qt-4c47079d367d44cf18b91965c351a5e9d834b343.tar.bz2 |
Simplify QDeclarativeGuard logic
-rw-r--r-- | src/declarative/qml/qdeclarativedata_p.h | 10 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 4a56536..e916273 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -152,11 +152,11 @@ public: template<class T> void QDeclarativeGuard<T>::addGuard() { - if (QObjectPrivate::get(o)->wasDeleted) { - if (prev) remGuard(); + Q_ASSERT(!prev); + + if (QObjectPrivate::get(o)->wasDeleted) return; - } - + QDeclarativeData *data = QDeclarativeData::get(o, true); next = data->guards; if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next; @@ -167,6 +167,8 @@ void QDeclarativeGuard<T>::addGuard() template<class T> void QDeclarativeGuard<T>::remGuard() { + Q_ASSERT(prev); + if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = prev; *prev = next; next = 0; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 19d4b57..8992d50 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -870,14 +870,10 @@ void QDeclarativeData::destroyed(QObject *object) if (ownContext && context) context->destroy(); - QDeclarativeGuard<QObject> *guard = guards; - while (guard) { - QDeclarativeGuard<QObject> *g = guard; - guard = guard->next; - g->o = 0; - g->prev = 0; - g->next = 0; - g->objectDestroyed(object); + while (guards) { + QDeclarativeGuard<QObject> *guard = guards; + *guard = (QObject *)0; + guard->objectDestroyed(object); } if (scriptValue) |