aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmldata_p.h7
-rw-r--r--src/qml/qml/v4/qv4mm.cpp4
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp3
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;