From b1a2c519af2592beeaf1dfccdae2ec245492c92b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 2 Feb 2018 10:24:57 +0100 Subject: QQmlDelegateModel: check incubationTask before accessing it A QQmlDelegateModelItem will have its incubation task removed when the item has finished loading. So we need to check that it exists before trying to access it. And we know that the item is ready (and not in error state) if the item still exists in the cache. Change-Id: If25dca6b5902c491f5061b8d5d84046a72a8029b Reviewed-by: Richard Moe Gustavsen --- src/qml/types/qqmldelegatemodel.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index fa1be563b5..491a918ce4 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1044,7 +1044,10 @@ QQmlIncubator::Status QQmlDelegateModel::incubationStatus(int index) if (!it->inCache()) return QQmlIncubator::Null; - return d->m_cache.at(it.cacheIndex)->incubationTask->status(); + if (auto incubationTask = d->m_cache.at(it.cacheIndex)->incubationTask) + return incubationTask->status(); + + return QQmlIncubator::Ready; } QString QQmlDelegateModelPrivate::stringValue(Compositor::Group group, int index, const QString &name) @@ -3194,7 +3197,10 @@ QQmlIncubator::Status QQmlPartsModel::incubationStatus(int index) if (!it->inCache()) return QQmlIncubator::Null; - return model->m_cache.at(it.cacheIndex)->incubationTask->status(); + if (auto incubationTask = model->m_cache.at(it.cacheIndex)->incubationTask) + return incubationTask->status(); + + return QQmlIncubator::Ready; } int QQmlPartsModel::indexOf(QObject *item, QObject *) const -- cgit v1.2.3