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

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