From f18dc91da5924256de54cfe05ca8f75f03a8a829 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 9 Jul 2015 10:48:21 +0200 Subject: [PATCH] Fix crash when mixing widgets with QtQuick 1 and Qt Quick 2 Apply the fix from commit 313a74cc4a9a5d200b2059d3d8767fe1a274c50d also to the QWidget and the QGraphicsObject destructor. Task-number: QTCREATORBUG-10273 Change-Id: I47983b49cc4d9b75a2e1ee838e13403bc4b95a59 Reviewed-by: Friedemann Kleint --- src/widgets/graphicsview/qgraphicsitem.cpp | 11 +++++++---- src/widgets/kernel/qwidget.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index c9a9cf9d79..1332134000 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1425,10 +1425,13 @@ QGraphicsItem::~QGraphicsItem() QObjectPrivate *p = QObjectPrivate::get(o); p->wasDeleted = true; if (p->declarativeData) { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(p->declarativeData, o); - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o); + if (static_cast(p->declarativeData)->ownedByQml1) { + if (QAbstractDeclarativeData::destroyed_qml1) + QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o); + } else { + if (QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(p->declarativeData, o); + } p->declarativeData = 0; } } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index dbb229484b..ba0fcf75d0 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1633,10 +1633,13 @@ QWidget::~QWidget() } if (d->declarativeData) { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(d->declarativeData, this); - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); + if (static_cast(d->declarativeData)->ownedByQml1) { + if (QAbstractDeclarativeData::destroyed_qml1) + QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); + } else { + if (QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(d->declarativeData, this); + } d->declarativeData = 0; // don't activate again in ~QObject }