aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2013-05-21 16:09:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-23 11:22:56 +0200
commit8a3d48915c29484c9ffb2fb8f0e3b569a9fe9b44 (patch)
tree7a6086508cdaa88e37e8ec1ac2c576ac0b59bf1a /src
parent0e9cd8b4098661bf611fa73a787c58c85e7d7338 (diff)
Do not return cacheItem->object if it is still incubating
It can happen that cacheItem->object in QQmlDelegateModelPrivate::object already has a value but that the cacheItem->incubationTask is still Loading. If we return the object here we can confuse some of QQmlDelegateModel consumers like QQuickItemView. E.g. in QQuickItemView if we get to return the object before the createdItem signal is emitted we will make that when the createdItem signal happens QQuickItemView::createdItem will be called it will add the item to unrequestedItems items and will expect that layout/refill will remove it from unrequestedItems if it is really one of the items we are creating, but as it has been already created the item will wrongly remain in unrequestedItems making the item view to act weird Task-number: QTBUG-28403 Change-Id: I4359391eb2a4012afd3f01d082a99692d63b6639 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index edc36ab630..53b8a3c79d 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -780,11 +780,16 @@ void QQmlDelegateModelPrivate::emitDestroyingPackage(QQuickPackage *package)
QQmlDelegateModelGroupPrivate::get(m_groups[i])->destroyingPackage(package);
}
+static bool isDoneIncubating(QQmlIncubator::Status status)
+{
+ return status == QQmlIncubator::Ready || status == QQmlIncubator::Error;
+}
+
void QQDMIncubationTask::statusChanged(Status status)
{
if (vdm) {
vdm->incubatorStatusChanged(this, status);
- } else if (status == QQmlIncubator::Ready || status == QQmlIncubator::Error) {
+ } else if (isDoneIncubating(status)) {
Q_ASSERT(incubating);
// The model was deleted from under our feet, cleanup ourselves
if (incubating->object) {
@@ -824,7 +829,7 @@ void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem)
void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incubationTask, QQmlIncubator::Status status)
{
Q_Q(QQmlDelegateModel);
- if (status != QQmlIncubator::Ready && status != QQmlIncubator::Error)
+ if (!isDoneIncubating(status))
return;
QQmlDelegateModelItem *cacheItem = incubationTask->incubating;
@@ -951,7 +956,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo
// Remove the temporary reference count.
cacheItem->scriptRef -= 1;
- if (cacheItem->object)
+ if (cacheItem->object && (!cacheItem->incubationTask || isDoneIncubating(cacheItem->incubationTask->status())))
return cacheItem->object;
cacheItem->releaseObject();