From c29e4836071a7bcd123b43cc113352dc6a7543be Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Mon, 1 Oct 2018 20:41:50 +0200 Subject: [PATCH] GenericProject: fix sorting file list when appending an entry pos was -1 for a value that should have been appended as last element to the list. Unfortunately, list->insert treats -1 as prepending in front of the list, which lead to incorrectly sorted lists. The function got broken during the review process of the introducing commit 758544c0581a70f87d375692ff93d. Change-Id: I693e4d79b0d493deeac0ea8781d637fe50d008b8 Reviewed-by: Orgad Shaneh Reviewed-by: Tobias Hunger --- src/plugins/genericprojectmanager/genericproject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index f1a47947eb3..edeac3eec4a 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -239,7 +239,10 @@ bool GenericProject::saveRawList(const QStringList &rawList, const QString &file static void insertSorted(QStringList *list, const QString &value) { int pos = Utils::indexOf(*list, [value](const QString &s) { return s > value; }); - list->insert(pos, value); + if (pos == -1) + list->append(value); + else + list->insert(pos, value); } bool GenericProject::addFiles(const QStringList &filePaths)