summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-05 08:42:46 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-05 09:06:28 (GMT)
commit118c82b0988c671045de448ffabc7ba95f015a69 (patch)
treeb197c6d6d896b102c53d1a5c104a1019fe41820d /src/gui
parentdecc287134139c61da5610afc060a6ca8d09f368 (diff)
downloadQt-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 'src/gui')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 8594968..f7d5f1b 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2666,6 +2666,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QModelIndex current = start;
QModelIndexList match;
QModelIndex firstMatch;
+ QModelIndex startMatch;
QModelIndexList previous;
do {
match = d->model->match(current, Qt::DisplayRole, searchString);
@@ -2682,6 +2683,12 @@ void QAbstractItemView::keyboardSearch(const QString &search)
if (row >= d->model->rowCount(firstMatch.parent()))
row = 0;
current = firstMatch.sibling(row, firstMatch.column());
+
+ //avoid infinite loop if all the matching items are disabled.
+ if (!startMatch.isValid())
+ startMatch = firstMatch;
+ else if (startMatch == firstMatch)
+ break;
}
} while (current != start && firstMatch.isValid());
}