From: Thomas McGuire Date: Tue, 14 Aug 2012 12:17:10 +0000 (+0200) Subject: Immediatley delete QV8QObjectResource objects to reduce memory leaks X-Git-Tag: 1.0_branch~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4573dd927991937751f1e56cc02f7946f4f182b;p=profile%2Fivi%2Fqtdeclarative.git Immediatley delete QV8QObjectResource objects to reduce memory leaks This reduces memory leaks when deleting the v8 engine. Otherwise, the memory would only be reclaimed during a full GC run, which might not happen at all. Change-Id: Iac34bad1f2280adc530d3b3d7a074c5d022005a4 Reviewed-by: Aaron Kennedy Reviewed-by: Chris Adams --- diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 58a7520..627e453 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -926,12 +926,16 @@ static void FastValueSetterReadOnly(v8::Local property, v8::Local handle, void *wrapper) { Q_ASSERT(handle->IsObject()); - QV8QObjectResource *resource = v8_resource_check(handle->ToObject()); + v8::Handle v8object = handle->ToObject(); + QV8QObjectResource *resource = v8_resource_check(v8object); Q_ASSERT(resource); static_cast(wrapper)->unregisterWeakQObjectReference(resource); if (static_cast(wrapper)->deleteWeakQObject(resource, false)) { - qPersistentDispose(handle); // dispose. + // dispose + v8object->SetExternalResource(0); + delete resource; + qPersistentDispose(handle); } else { handle.MakeWeak(0, WeakQObjectReferenceCallback); // revive. }