qt5-qtdeclarative/0009-V4-Do-not-call-dtor-of-an-object-we-continue-to-use.patch

52 lines
1.8 KiB
Diff
Raw Normal View History

2023-01-05 12:09:21 +00:00
From b964ba12bf118afbbf42cd9e4e7b4903ad107060 Mon Sep 17 00:00:00 2001
2022-03-04 11:51:47 +00:00
From: Ulf Hermann <ulf.hermann@qt.io>
Date: Thu, 3 Feb 2022 10:02:06 +0100
2023-01-05 12:09:21 +00:00
Subject: [PATCH 09/21] V4: Do not call dtor of an object we continue to use
2022-03-04 11:51:47 +00:00
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.
Pick-to: 5.15 6.2 6.3
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)
---
src/qml/jsruntime/qv4qobjectwrapper.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
2023-01-05 12:09:21 +00:00
index e57cdd8278..94613598af 100644
2022-03-04 11:51:47 +00:00
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
2023-01-05 12:09:21 +00:00
@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
2022-03-04 11:51:47 +00:00
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);
2023-01-05 12:09:21 +00:00
@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
2022-03-04 11:51:47 +00:00
}
}
- h->~Data();
+ h->destroy();
}
--
2023-01-05 12:09:21 +00:00
2.39.0
2022-03-04 11:51:47 +00:00