diff options
author | Alan Alpert <aalpert@rim.com> | 2013-01-24 17:31:41 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-29 19:18:04 +0100 |
commit | d005c5c80b6fff835adb350a780d80348549bc64 (patch) | |
tree | ebfebf0916884e6bb377c4883335b0bc93e87572 /src | |
parent | 6327d2947162b54d0618353c015190a64706c318 (diff) |
Strengthen reference to var properties during construction
Normally var properties are kept alive by a reference to the object they
are declared on, but during the construction of that object the GC may
not be aware of said object. This change uses a strong reference during
GC passes which take place while the object is being constructed.
Task-number: QTBUG-29138
Change-Id: Ieecfcc7567aefac0d67cb933728daf16ed3eed0a
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 3fe3d28b67..2619c1a484 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -813,6 +813,12 @@ QDateTime QV8Engine::qtDateTimeFromJsDate(double jsDate) v8::Persistent<v8::Object> *QV8Engine::findOwnerAndStrength(QObject *object, bool *shouldBeStrong) { + QQmlData *data = QQmlData::get(object); + if (data && data->rootObjectInCreation) { // When the object is still being created it may not show up to the GC. + *shouldBeStrong = true; + return 0; + } + QObject *parent = object->parent(); if (!parent) { // if the object has JS ownership, the object's v8object owns the lifetime of the persistent value. |