ProjectExplorer: Fix FolderNode::addNestedNode

std::lower_bound returns the first entry that is greater than or
equal to the argument. It should never return anything smaller
than the argument, so the condition did not make sense.

This broke the project tree of Qt Creator's cmake project (and likely other
projects as well).

Invert the condition to make it clearer.

This amends commit 18ecbb9b14.

Change-Id: I99a002b5fb2c4ea6639b896ce8d2ef2b01f0815b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Orgad Shaneh
2019-12-02 05:59:19 +02:00
committed by Orgad Shaneh
parent d3b2c01c11
commit 83be2cc026

View File

@@ -648,13 +648,13 @@ void FolderNode::addNestedNodes(std::vector<std::unique_ptr<FileNode> > &&files,
const Utils::FilePath parentDir = f->filePath().parentDir();
const auto it = std::lower_bound(fileNodesPerDir.begin(), fileNodesPerDir.end(), parentDir,
[](const DirWithNodes &nad, const Utils::FilePath &dir) { return nad.first < dir; });
if (it == fileNodesPerDir.end() || it->first < parentDir) {
if (it != fileNodesPerDir.end() && it->first == parentDir) {
it->second.emplace_back(std::move(f));
} else {
DirWithNodes dirWithNodes;
dirWithNodes.first = parentDir;
dirWithNodes.second.emplace_back(std::move(f));
fileNodesPerDir.insert(it, std::move(dirWithNodes));
} else {
it->second.emplace_back(std::move(f));
}
}