From 82b0b31fe47a6a54c500f2cbea45b37fc28f3bee Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Mon, 2 May 2016 13:11:26 +0200 Subject: Fix crash for unknown QQmlListModel roles in debug builds If a role is unknown, trying to access it will crash in getExistingRole. Fixed that and now return QVariant() for unknown roles. Change-Id: Iad5c1292a4faee893fbc5a69984cf776aca85d70 Reviewed-by: Shawn Rutledge Reviewed-by: Robin Burchell --- src/qml/types/qqmllistmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml') diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 4b0aa47c63..3d71621290 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -392,6 +392,8 @@ void ListModel::updateCacheIndices() QVariant ListModel::getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng) { + if (roleIndex >= m_layout->roleCount()) + return QVariant(); ListElement *e = elements[elementIndex]; const ListLayout::Role &r = m_layout->getExistingRole(roleIndex); return e->getProperty(r, owner, eng); -- cgit v1.2.3