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 758544c058.

Change-Id: I693e4d79b0d493deeac0ea8781d637fe50d008b8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Andre Hartmann
2018-10-01 20:41:50 +02:00
committed by André Hartmann
parent 36b654567d
commit c29e483607

View File

@@ -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)