diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-02-03 10:02:06 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-04 00:37:49 +0000 |
commit | 87888b1ff87404c7c74724963fa038ffad442427 (patch) | |
tree | d9aa88c886f74effd4fb02d0989f97fb6b09e43c | |
parent | 114826a9f6f39aa85a4bf645d49da891e9e3c124 (diff) |
V4: Do not call dtor of an object we continue to use
After destroyObject(), the QObjectWrapper is still alive. We might use
its heap object again. Furthermore, the Heap::QObjectWrapper dtor does
not actually do anything defined. What we want to do here is clear the
QObject pointer because we've just gotten rid of the QObject. There is a
method for that: Heap::QObjectWrapper::destroy().
Finally, the internalClass must never ever be nullptr. Assert on that
rather than checking it.
Task-number: QTBUG-100431
Change-Id: I794a295c182b2ed4ba80673f58d6143c861b7391
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 6c197319f34b8098d034f1543eb5feb9d7be54c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 5a706006f8..21ac5e448a 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1237,8 +1237,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta void QObjectWrapper::destroyObject(bool lastCall) { Heap::QObjectWrapper *h = d(); - if (!h->internalClass) - return; // destroyObject already got called + Q_ASSERT(h->internalClass); if (h->object()) { QQmlData *ddata = QQmlData::get(h->object(), false); @@ -1268,7 +1267,7 @@ void QObjectWrapper::destroyObject(bool lastCall) } } - h->~Data(); + h->destroy(); } |