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

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