Python: preserve sorted state of project files

Change-Id: I77cd9d9bac93a04d0e30beda8541862a1cd5371f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-06-12 08:07:14 +02:00
parent c617c2afa1
commit 80e66ed172

View File

@@ -302,12 +302,21 @@ bool PythonBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *
{
const Utils::FilePath projectDir = projectDirectory();
auto comp = [](const FileEntry &left, const FileEntry &right) {
return left.rawEntry < right.rawEntry;
};
const bool isSorted = std::is_sorted(m_files.begin(), m_files.end(), comp);
for (const FilePath &filePath : filePaths) {
if (!projectDir.isSameDevice(filePath))
return false;
m_files.append(FileEntry{filePath.relativePathFrom(projectDir).toString(), filePath});
}
if (isSorted)
std::sort(m_files.begin(), m_files.end(), comp);
return save();
}