diff options
Diffstat (limited to 'src/quick/items/qquickitemview.cpp')
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index c203f389ae..10f6c63170 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -1729,7 +1729,7 @@ void QQuickItemViewPrivate::updateCurrent(int modelIndex) FxViewItem *oldCurrentItem = currentItem; int oldCurrentIndex = currentIndex; currentIndex = modelIndex; - currentItem = createItem(modelIndex, false); + currentItem = createItem(modelIndex, QQmlIncubator::AsynchronousIfNested); if (oldCurrentItem && oldCurrentItem->attached && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); if (currentItem) { @@ -2325,11 +2325,11 @@ void QQuickItemViewPrivate::viewItemTransitionFinished(QQuickItemViewTransitiona When the item becomes available, refill() will be called and the item will be returned on the next call to createItem(). */ -FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, bool asynchronous) +FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, QQmlIncubator::IncubationMode incubationMode) { Q_Q(QQuickItemView); - if (requestedIndex == modelIndex && asynchronous) + if (requestedIndex == modelIndex && incubationMode == QQmlIncubator::Asynchronous) return 0; for (int i=0; i<releasePendingTransition.count(); i++) { @@ -2340,14 +2340,20 @@ FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, bool asynchronous) } } - if (asynchronous) - requestedIndex = modelIndex; inRequest = true; - QObject* object = model->object(modelIndex, asynchronous); + QObject* object = model->object(modelIndex, incubationMode); QQuickItem *item = qmlobject_cast<QQuickItem*>(object); + if (!item) { - if (object) { + if (!object) { + if (requestedIndex == -1 && model->incubationStatus(modelIndex) == QQmlIncubator::Loading) { + // The reason we didn't receive an item is because it's incubating async. We keep track + // of this by assigning the index we're waiting for to 'requestedIndex'. This will e.g. let + // the view avoid unnecessary layout calls until the item has been loaded. + requestedIndex = modelIndex; + } + } else { model->release(object); if (!delegateValidated) { delegateValidated = true; |