summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-22 06:47:18 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-22 06:53:44 (GMT)
commit5efe6549e5248fbe5b20c8a18fec64d248d7b87c (patch)
tree9f5464b540a223d8905d893d132e9a1b8a47476e /src/declarative
parent9490f107983197ca86e959d6470bd829a17642e5 (diff)
downloadQt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.zip
Qt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.tar.gz
Qt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.tar.bz2
Fix Loader crash.
If setting the source of a Loader triggered a change to the source (i.e. the thing being loaded set the source to something else) a crash would occur. We now no longer delete the component immediately when the source changes. Task-number: QTBUG-9241
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 6dbcd16..745734e 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -66,7 +66,7 @@ void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem
void QDeclarativeLoaderPrivate::clear()
{
if (ownComponent) {
- delete component;
+ component->deleteLater();
component = 0;
ownComponent = false;
}
@@ -285,7 +285,16 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
return;
}
+ QDeclarativeComponent *c = component;
QObject *obj = component->create(ctxt);
+ if (component != c) {
+ // component->create could trigger a change in source that causes
+ // component to be set to something else. In that case we just
+ // need to cleanup.
+ delete obj;
+ delete ctxt;
+ return;
+ }
if (obj) {
ctxt->setParent(obj);
item = qobject_cast<QGraphicsObject *>(obj);