aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-29 14:09:55 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-06 13:06:05 +0000
commit77aefc95cf3fbae342004513fd8c9f3a0184eba9 (patch)
tree4310042298458dd94aac126d833f395ea227d00b /src/qml/types
parent638f80c317a42d51ff312c077cc84f60538e5498 (diff)
QQmlTableInstanceModel: 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, we just print a warning, and return nullptr, which will let TableView handle the situation gracefully. Change-Id: Ibaf9da09fd11149362f5b674fc61db47593de10c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmltableinstancemodel.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qml/types/qqmltableinstancemodel.cpp b/src/qml/types/qqmltableinstancemodel.cpp
index 33d13e3bad..1054158dc8 100644
--- a/src/qml/types/qqmltableinstancemodel.cpp
+++ b/src/qml/types/qqmltableinstancemodel.cpp
@@ -109,19 +109,19 @@ QQmlTableInstanceModel::~QQmlTableInstanceModel()
QQmlComponent *QQmlTableInstanceModel::resolveDelegate(int index)
{
- QQmlComponent *delegate = nullptr;
if (m_delegateChooser) {
const int row = m_adaptorModel.rowAt(index);
const int column = m_adaptorModel.columnAt(index);
+ QQmlComponent *delegate = nullptr;
QQmlAbstractDelegateComponent *chooser = m_delegateChooser;
do {
delegate = chooser->delegate(&m_adaptorModel, row, column);
chooser = qobject_cast<QQmlAbstractDelegateComponent *>(delegate);
} while (chooser);
+ return delegate;
}
- if (!delegate)
- delegate = m_delegate;
- return delegate;
+
+ return m_delegate;
}
QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
@@ -132,6 +132,8 @@ QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
return modelItem;
QQmlComponent *delegate = resolveDelegate(index);
+ if (!delegate)
+ return nullptr;
// Check if the pool contains an item that can be reused
modelItem = takeFromReusableItemsPool(delegate);