36 lines
1.2 KiB
Diff
36 lines
1.2 KiB
Diff
From 4d375f3f2b95bfcb322402df3525db6cc7a723ce Mon Sep 17 00:00:00 2001
|
|
From: Erik Verbruggen <erik.verbruggen@digia.com>
|
|
Date: Tue, 4 Oct 2016 11:42:10 +0200
|
|
Subject: [PATCH 26/82] QML: Clear weak references on Object destruction for
|
|
C++-owned QObjects
|
|
|
|
Otherwise a re-use of the C++-owned QObject will have a back reference
|
|
to a possibly GCed QV4::QObjectWrapper, which results in exciting
|
|
behavior.
|
|
|
|
Task-number: QTBUG-46263
|
|
Change-Id: Iff0e36f9e67c01abd02cfb5a89605d0f26ddb0de
|
|
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|
---
|
|
src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 ++++
|
|
1 file changed, 4 insertions(+)
|
|
|
|
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
|
|
index 246df4c..77de84b 100644
|
|
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
|
|
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
|
|
@@ -1042,6 +1042,10 @@ void QObjectWrapper::destroyObject(bool lastCall)
|
|
delete h->object;
|
|
else
|
|
h->object->deleteLater();
|
|
+ } else {
|
|
+ // If the object is C++-owned, we still have to release the weak reference we have
|
|
+ // to it.
|
|
+ ddata->jsWrapper.clear();
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.9.3
|
|
|