summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-05 10:42:46 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-05 11:06:28 +0200
commit118c82b0988c671045de448ffabc7ba95f015a69 (patch)
treeb197c6d6d896b102c53d1a5c104a1019fe41820d /src/gui/itemviews
parentdecc287134139c61da5610afc060a6ca8d09f368 (diff)
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/itemviews')
-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 8594968097..f7d5f1b9ed 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());
}