From 7e4d10bb7f06e7369452d2683ba999e90c27d06b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 3 Feb 2010 11:02:23 +1000 Subject: Fix Loader crash when Loader.item causes a new item to be loaded Task-number: QT-2338 --- src/declarative/graphicsitems/qmlgraphicsloader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index bb1020c..7cd4d1a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -64,8 +64,14 @@ void QmlGraphicsLoaderPrivate::clear() } source = QUrl(); - delete item; - item = 0; + if (item) { + // We can't delete immediately because our item may have triggered + // the Loader to load a different item. + item->setVisible(false); + static_cast(item)->setParentItem(0); + item->deleteLater(); + item = 0; + } } void QmlGraphicsLoaderPrivate::initResize() -- cgit v0.12