diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-29 12:18:31 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-05-29 15:54:26 +0200 |
commit | da79a51d955d701b458b410b80c2a7585f1333be (patch) | |
tree | 196f7fe4ef8b11fab1333cedbfd7f5d4a6e025b5 /src/qml | |
parent | 5998ab3d4d111a536eb44e74aa901aa103b0bfc3 (diff) |
Fix failing tst_qqmlecmascript::deleteRootObjectDuringCreation unit test
Respect the rootObjectInCreation flag in QQmlData. Centralize the checking code
for that through the places in the engine where it is checked, along with the
indestructible flag.
Change-Id: Ie977b34ac8d070f6dcd7bab11a95dd27ca25145e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmldata_p.h | 7 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4mm.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper.cpp | 3 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 98407e53b5..568a43e36e 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -200,6 +200,13 @@ public: } } + static bool keepAliveDuringGarbageCollection(const QObject *object) { + QQmlData *ddata = get(object); + if (!ddata || ddata->indestructible || ddata->rootObjectInCreation) + return true; + return false; + } + bool hasExtendedData() const { return extendedData != 0; } QHash<int, QObject *> *attachedProperties() const; diff --git a/src/qml/qml/v4/qv4mm.cpp b/src/qml/qml/v4/qv4mm.cpp index aca838a515..fcc660e3db 100644 --- a/src/qml/qml/v4/qv4mm.cpp +++ b/src/qml/qml/v4/qv4mm.cpp @@ -303,14 +303,14 @@ void MemoryManager::mark() QObject *qobject = qobjectWrapper->object; if (!qobject) continue; - bool keepAlive = QQmlEngine::objectOwnership(qobject) == QQmlEngine::CppOwnership; + bool keepAlive = QQmlData::keepAliveDuringGarbageCollection(qobject); if (!keepAlive) { if (QObject *parent = qobject->parent()) { while (parent->parent()) parent = parent->parent(); - keepAlive = QQmlEngine::objectOwnership(parent) == QQmlEngine::CppOwnership; + keepAlive = QQmlData::keepAliveDuringGarbageCollection(parent); } } diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index fdf07389c2..8c884c492d 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -1964,8 +1964,7 @@ QV4::Value QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, Value *args { if (!m_object) return QV4::Value::undefinedValue(); - QQmlData *ddata = QQmlData::get(m_object, false); - if (!ddata || ddata->indestructible || ddata->rootObjectInCreation) + if (QQmlData::keepAliveDuringGarbageCollection(m_object)) ctx->throwError(QStringLiteral("Invalid attempt to destroy() an indestructible object")); int delay = 0; |