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>
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.