aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-29 15:03:49 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-06 10:58:39 +0000
commitedb79c31ab18a051d496d517ec65aed460f3c1f5 (patch)
treedd8a5b35e35cfd76c2e215678b9638e26c72002e /tests
parentfa74444ed06e4db21b0e9829a5832b886b39d372 (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 'tests')
-rw-r--r--tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml63
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp11
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml
new file mode 100644
index 0000000000..45164222f2
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import Qt.labs.qmlmodels 1.0
+
+Item {
+ width: 640
+ height: 450
+
+ ListView {
+ width: 600
+ height: 400
+ model: 2
+ delegate: DelegateChooser {
+ DelegateChoice {
+ index: 0
+ delegate: Rectangle {
+ width: 100
+ height: 100
+ color:"green"
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 9c11957894..1ca341fe66 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -267,6 +267,8 @@ private slots:
void QTBUG_34576_velocityZero();
void QTBUG_61537_modelChangesAsync();
+ void useDelegateChooserWithoutDefault();
+
void addOnCompleted();
private:
@@ -8858,6 +8860,15 @@ void tst_QQuickListView::addOnCompleted()
}
}
+void tst_QQuickListView::useDelegateChooserWithoutDefault()
+{
+ // Check that the application doesn't crash
+ // if the delegate chooser doesn't cover all cells
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("usechooserwithoutdefault.qml"));
+ window->show();
+};
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"