diff --git a/src/plugins/python/pythonproject.cpp b/src/plugins/python/pythonproject.cpp index 50ffe379943..c9bb0f0b6ce 100644 --- a/src/plugins/python/pythonproject.cpp +++ b/src/plugins/python/pythonproject.cpp @@ -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(); }