diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-05 08:42:46 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-05 09:06:28 (GMT) |
commit | 118c82b0988c671045de448ffabc7ba95f015a69 (patch) | |
tree | b197c6d6d896b102c53d1a5c104a1019fe41820d /tests/auto/qlistwidget | |
parent | decc287134139c61da5610afc060a6ca8d09f368 (diff) | |
download | Qt-118c82b0988c671045de448ffabc7ba95f015a69.zip Qt-118c82b0988c671045de448ffabc7ba95f015a69.tar.gz Qt-118c82b0988c671045de448ffabc7ba95f015a69.tar.bz2 |
Fixes hangup when pressing key in QListWidget
If there is severals matching items but all of them are disabled, it
would have produced an infinite loop.
Block the loop once we reach an already matched item.
Task-number: 258949
Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qlistwidget')
-rw-r--r-- | tests/auto/qlistwidget/tst_qlistwidget.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index a56a470..e38ef20 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -128,6 +128,8 @@ private slots: void setSortingEnabled(); void task199503_crashWhenCleared(); void task217070_scrollbarsAdjusted(); + void task258949_keypressHangup(); + protected slots: void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last) @@ -994,7 +996,7 @@ void tst_QListWidget::sortHiddenItems() for (int k = 0; k < tw->count(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); - + delete tw; } @@ -1498,5 +1500,24 @@ void tst_QListWidget::task217070_scrollbarsAdjusted() } } +void tst_QListWidget::task258949_keypressHangup() +{ + QListWidget lw; + for (int y = 0; y < 5; y++) { + QListWidgetItem *lwi = new QListWidgetItem(&lw); + lwi->setText(y ? "1" : "0"); + if (y) + lwi->setFlags(Qt::ItemIsSelectable); + } + + lw.show(); + lw.setCurrentIndex(lw.model()->index(0,0)); + QCOMPARE(lw.currentIndex(), lw.model()->index(0,0)); + QTest::qWait(30); + QTest::keyPress(&lw, '1'); //this used to freeze + QTest::qWait(30); + QCOMPARE(lw.currentIndex(), lw.model()->index(0,0)); +} + QTEST_MAIN(tst_QListWidget) #include "tst_qlistwidget.moc" |