Qt: Fix a recent files infinite loop.

QListWidget::takeItem does nothing if the row is invalid. This is the
case when we pass it ::count(). Make sure that we remove a valid row and
that our loop will terminate.

Follow-up to g174dc98.

Change-Id: I7e695cc04b2f3b5c28a8cc70af0579d787ff8737
Reviewed-on: https://code.wireshark.org/review/15417
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2016-05-13 11:13:07 -07:00
parent 4ec84a3e2b
commit 43776d4b73
1 changed files with 4 additions and 2 deletions

View File

@ -384,8 +384,10 @@ void MainWelcome::updateRecentFiles() {
rfRow++;
}
while ((unsigned)recent_files_->count() > prefs.gui_recent_files_count_max) {
recent_files_->takeItem(recent_files_->count());
int row = recent_files_->count();
while (row > 0 && row > (int) prefs.gui_recent_files_count_max) {
row--;
recent_files_->takeItem(row);
}
if (recent_files_->count() > 0) {
welcome_ui_->openFrame->animatedShow();