summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-18 16:07:27 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-20 06:36:29 +0100
commit95092e20113c3c69332b67a50e0c104cebb96932 (patch)
tree854d1ca1b1211f926475d94a8cfa701b3422d9ea /tests/auto/widgets
parentebd33883e79b458639e8fe118ccc285641223203 (diff)
Make setting twice the very same model on QComboBox a no-op
Basically, introduce a small check for this corner-case situation. Setting a model doesn't just store a pointer, but also resets the current index, changes the line edit completion model, and so on, and seems silly to trigger changes in such cases. [ChangeLog][QtWidgets][QComboBox] A QComboBox does not reset itself any more when setting the same model more than once. Change-Id: If028b36cdfaa5552c156dd900e123ca9a04d4e3d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index ac32ee4968..556602b523 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -1576,6 +1576,12 @@ void tst_QComboBox::setModel()
box.setModel(new QStandardItemModel(2,1, &box));
QCOMPARE(box.currentIndex(), 0);
QVERIFY(box.model() != oldModel);
+
+ // check that setting the very same model doesn't move the current item
+ box.setCurrentIndex(1);
+ QCOMPARE(box.currentIndex(), 1);
+ box.setModel(box.model());
+ QCOMPARE(box.currentIndex(), 1);
}
void tst_QComboBox::setCustomModelAndView()