diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-29 15:03:49 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-09-06 10:58:39 +0000 |
commit | edb79c31ab18a051d496d517ec65aed460f3c1f5 (patch) | |
tree | dd8a5b35e35cfd76c2e215678b9638e26c72002e /src/qml/types | |
parent | fa74444ed06e4db21b0e9829a5832b886b39d372 (diff) |
QQmlDelegateModel: don't fall back to use DelegateChooser as delegate
If the application uses a DelegateChooser, but the chooser fails to
resolve a delegate for a certain index, it should not use itself
as the delegate instead. This will cause the application to crash.
Instead, return nullptr (like we do in the function guard), which
will let the item views handle the situation gracefully.
Change-Id: I9b3b4aa2626d1f8521b4395096300ac12150c63f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 6732be9844..015458169a 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1049,16 +1049,16 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ cacheItem->incubationTask->forceCompletion(); } } else if (!cacheItem->object) { - QQmlComponent *delegate = nullptr; + QQmlComponent *delegate = m_delegate; if (m_delegateChooser) { QQmlAbstractDelegateComponent *chooser = m_delegateChooser; do { delegate = chooser->delegate(&m_adaptorModel, index); chooser = qobject_cast<QQmlAbstractDelegateComponent *>(delegate); } while (chooser); + if (!delegate) + return nullptr; } - if (!delegate) - delegate = m_delegate; QQmlContext *creationContext = delegate->creationContext(); |