Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.2.6
-
None
-
-
c4b62ee50 (dev), 0f664ee6e (6.5), 4e927c639 (tqtc/lts-6.2)
Description
This is a regression from QTBUG-103007. In cases where the combo box's model has been modified each subsequent call to setCurrentIndex(-1) will emit a currentIndexChanged signal.
QStandardItemModel model; model.appendRow(new QStandardItem("a")); model.appendRow(new QStandardItem("b")); QComboBox combo; combo.setModel(&model); QSignalSpy spy(&combo, QOverload<int>::of(&QComboBox::currentIndexChanged)); combo.setCurrentIndex(-1); QCOMPARE(spy.count(), 1); //Setting it to the same thing shouldn't emit currentIndexChanged combo.setCurrentIndex(-1); QCOMPARE(spy.count(), 1); combo.setCurrentIndex(1); QCOMPARE(spy.count(), 2); //This will set "indexBeforeChange" to 1. It won't change until we update the model again model.appendRow(new QStandardItem("c")); combo.setCurrentIndex(-1); QCOMPARE(spy.count(), 3); //Because of QTBUG-103007 it will emit currentIndexChanged now. It didn't in QT5. combo.setCurrentIndex(-1); QCOMPARE(spy.count(), 3);