From 56212aa9ca09bc643bde40bc6f028009ae1d3859 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 27 Dec 2011 11:46:43 +0200 Subject: [PATCH] GUI: Remove empty/space-only items from MRU list. --- gui/mainwindow.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index fb31dcafe..e9b2ff39f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1014,6 +1014,20 @@ void MainWindow::UpdateMRUMenuItems() } QStringList projects = mSettings->value(SETTINGS_MRU_PROJECTS).toStringList(); + + // Do a sanity check - remove duplicates and empty or space only items + int removed = projects.removeDuplicates(); + for (int i = projects.size() - 1; i >= 0; i--) { + QString text = projects[i].trimmed(); + if (text.isEmpty()) { + projects.removeAt(i); + removed++; + } + } + + if (removed) + mSettings->setValue(SETTINGS_MRU_PROJECTS, projects); + const int numRecentProjects = qMin(projects.size(), (int)MaxRecentProjects); for (int i = 0; i < numRecentProjects; i++) { const QString filename = QFileInfo(projects[i]).fileName();