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 <simon.hausmann@qt.io>
bb10
Lars Knoll 2017-11-14 15:52:34 +01:00 committed by Nathan Collins
parent a91b91ae57
commit 3e91625b58
1 changed files with 2 additions and 1 deletions

View File

@ -1677,6 +1677,7 @@ QWidget::~QWidget()
}
}
d->wasDeleted = true;
if (d->declarativeData) {
if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
if (QAbstractDeclarativeData::destroyed_qml1)
@ -8451,7 +8452,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
data.is_closing = 1;
QPointer<QWidget> that = q;
QPointer<QWidget> parentWidget = q->parentWidget();
QPointer<QWidget> parentWidget = (q->parentWidget() && !QObjectPrivate::get(q->parentWidget())->wasDeleted) ? q->parentWidget() : nullptr;
bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose);
if (mode != CloseNoEvent) {