path: root/src/corelib/kernel/qobject.cpp
diff options
authorSimon Hausmann <>2013-12-06 16:19:08 +0100
committerThe Qt Project <>2013-12-06 17:38:26 +0100
commit313a74cc4a9a5d200b2059d3d8767fe1a274c50d (patch)
tree8152c47ba79daf30c6853e4e95c84cf6d9178d93 /src/corelib/kernel/qobject.cpp
parent7972553aca51587eb1dda80509ec66766e0743c2 (diff)
Fix QtDeclarative and QtQml co-existence part three ;(v5.2.0
Unfortunately the QObject destroyed callbacks for QtQml and QtDeclarative can't be called in sequence, because if the QQmlData has the ownsMemory bit set, then the destroyed callback will delete the QQmlData, and the sub-sequent call to the destroyed callback of qml1 will try to dereference the QQmlData's first bit (ownedByQml1), which is already destroyed. This patch fixes that by simply sharing the assumption of the first bit indicating module ownership (QtQml vs. QtDeclarative) also to qtbase and using it to distinguish between which destroyed callback function to call. Task-number: QTCREATORBUG-10273 Change-Id: I2773a31a3e9b3a1c22d1c1f33b2f29f3296cb3cf Reviewed-by: Olivier Goffart <> Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
1 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 3fbeaa8712..7e06e2c261 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -808,10 +808,13 @@ QObject::~QObject()
if (d->declarativeData) {
- if (QAbstractDeclarativeData::destroyed)
- QAbstractDeclarativeData::destroyed(d->declarativeData, this);
- if (QAbstractDeclarativeData::destroyed_qml1)
- QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+ if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+ if (QAbstractDeclarativeData::destroyed_qml1)
+ QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+ } else {
+ if (QAbstractDeclarativeData::destroyed)
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
+ }
// set ref to zero to indicate that this object has been deleted