Blame SOURCES/0019-V4-Do-not-call-dtor-of-an-object-we-continue-to-use.patch

77f9a9
From c8a4894655eef230702e6cc889f3d40fbb5a9426 Mon Sep 17 00:00:00 2001
77f9a9
From: Ulf Hermann <ulf.hermann@qt.io>
77f9a9
Date: Thu, 3 Feb 2022 10:02:06 +0100
77f9a9
Subject: [PATCH 19/20] V4: Do not call dtor of an object we continue to use
77f9a9
77f9a9
After destroyObject(), the QObjectWrapper is still alive. We might use
77f9a9
its heap object again. Furthermore, the Heap::QObjectWrapper dtor does
77f9a9
not actually do anything defined. What we want to do here is clear the
77f9a9
QObject pointer because we've just gotten rid of the QObject. There is a
77f9a9
method for that: Heap::QObjectWrapper::destroy().
77f9a9
77f9a9
Finally, the internalClass must never ever be nullptr. Assert on that
77f9a9
rather than checking it.
77f9a9
77f9a9
Pick-to: 5.15 6.2 6.3
77f9a9
Task-number: QTBUG-100431
77f9a9
Change-Id: I794a295c182b2ed4ba80673f58d6143c861b7391
77f9a9
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
77f9a9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
77f9a9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
77f9a9
(cherry picked from commit 6c197319f34b8098d034f1543eb5feb9d7be54c3)
77f9a9
---
77f9a9
 src/qml/jsruntime/qv4qobjectwrapper.cpp | 5 ++---
77f9a9
 1 file changed, 2 insertions(+), 3 deletions(-)
77f9a9
77f9a9
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
77f9a9
index 9899c9274e..272b85069f 100644
77f9a9
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
77f9a9
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
77f9a9
@@ -1160,8 +1160,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
77f9a9
 void QObjectWrapper::destroyObject(bool lastCall)
77f9a9
 {
77f9a9
     Heap::QObjectWrapper *h = d();
77f9a9
-    if (!h->internalClass)
77f9a9
-        return; // destroyObject already got called
77f9a9
+    Q_ASSERT(h->internalClass);
77f9a9
 
77f9a9
     if (h->object()) {
77f9a9
         QQmlData *ddata = QQmlData::get(h->object(), false);
77f9a9
@@ -1191,7 +1190,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
77f9a9
         }
77f9a9
     }
77f9a9
 
77f9a9
-    h->~Data();
77f9a9
+    h->destroy();
77f9a9
 }
77f9a9
 
77f9a9
 
77f9a9
-- 
77f9a9
2.35.1
77f9a9