summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2022-03-12 01:48:07 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-13 20:12:44 +0000
commit6a829e0d09bd81607d192040a1b6c3c12a58aad7 (patch)
tree87db706f2051cc5f7cc4abe903f4e0edf076e5f8 /tests
parent7037dfa74103731de6b4750b8be3e453faddf1fb (diff)
QCompleter: fix crash when setting the same model twice
Found when retesting the testcase completer.zip from QTBUG-54642 Change-Id: Id84eefeb3a33dc6d790cfa23755352381cc097a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 7382e5735ea734fe5e5777518394963593603c32) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 4146a6632d..358f5fe1e7 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -1653,6 +1653,16 @@ void tst_QComboBox::setModel()
QCOMPARE(box.rootModelIndex(), rootModelIndex);
box.setModel(box.model());
QCOMPARE(box.rootModelIndex(), rootModelIndex);
+
+ // check that setting the same model as the completer's doesn't crash
+ QCompleter *completer = new QCompleter(&box);
+ box.setEditable(true);
+ box.setCompleter(completer);
+ auto *listModel = new QStringListModel({ "one", "two" }, completer);
+ completer->setModel(listModel);
+ QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ box.setModel(listModel);
+ QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
}
void tst_QComboBox::setCustomModelAndView()