aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-03-13 13:30:39 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-15 02:44:40 +0100
commit25793276e52240e4dfad297dc5b9eb282ed3f5e6 (patch)
tree2c28122e886334703cd3f6cdd17cba759209b313 /src/qml/qml/v8
parent147247a31a9d6c1edadb0c7c78cf10b894dfab25 (diff)
Fix crash caused by dereferencing collected v8 data
If a var property of a QObject is read after the v8 data associated with the qobject has been deleted but prior to the DeferredDelete event being processed, the varProperties array will be null and a crash will occur. This patch ensures that we check for this condition in both the access and set codepaths for var properties, and also ensures that an object which has previously been queued for deletion cannot be referenced in JS. Finally, it adds a unit test to ensure that we don't regress. Task-number: QTBUG-24748 Change-Id: Idde384ca01e18f4dcf9e376e9379f2c5eb410e14 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index a483346dd1..3faea2c97b 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -883,8 +883,10 @@ static void WeakQObjectReferenceCallback(v8::Persistent<v8::Value> handle, void
QQmlData *ddata = QQmlData::get(object, false);
if (ddata) {
ddata->v8object.Clear();
- if (!object->parent() && !ddata->indestructible)
+ if (!object->parent() && !ddata->indestructible) {
+ ddata->isQueuedForDeletion = true;
object->deleteLater();
+ }
}
}
@@ -1043,12 +1045,15 @@ v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
if (QObjectPrivate::get(object)->wasDeleted)
return v8::Null();
-
+
QQmlData *ddata = QQmlData::get(object, true);
if (!ddata)
return v8::Undefined();
+ if (ddata->isQueuedForDeletion)
+ return v8::Null();
+
if (ddata->v8objectid == m_id && !ddata->v8object.IsEmpty()) {
// We own the v8object
return v8::Local<v8::Object>::New(ddata->v8object);