summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-10-04 11:42:10 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-10-05 08:26:42 +0000
commit4d375f3f2b95bfcb322402df3525db6cc7a723ce (patch)
tree37632474b6e60edc1264cf89323440735e3918b6 /src
parent55b3d76671090da348d63a89417ea73dab5d315d (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 246df4c4e9..77de84bf90 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();
}
}
}