From 3e91625b58b4d7d2757678de9d77eef91e84df36 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 14 Nov 2017 15:52:34 +0100 Subject: [PATCH] Fix QML integration of widgets We need to mark the object as deleted before destroying it's declarative data, otherwise all sorts of bad things can happen. This fixes the qwidgetsinqml autotest in qtdeclarative. Change-Id: I05a645ebe1ca7a50c8927e3dbd9ebb5aaf369a71 Reviewed-by: Simon Hausmann --- src/widgets/kernel/qwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 923245c53c..c947acd765 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1677,6 +1677,7 @@ QWidget::~QWidget() } } + d->wasDeleted = true; if (d->declarativeData) { if (static_cast(d->declarativeData)->ownedByQml1) { if (QAbstractDeclarativeData::destroyed_qml1) @@ -8451,7 +8452,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode) data.is_closing = 1; QPointer that = q; - QPointer parentWidget = q->parentWidget(); + QPointer parentWidget = (q->parentWidget() && !QObjectPrivate::get(q->parentWidget())->wasDeleted) ? q->parentWidget() : nullptr; bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); if (mode != CloseNoEvent) {