diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 4f265650797..aebc97270f4 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2495,6 +2495,13 @@ FilePairs ProjectExplorerPlugin::renameFiles( = Utils::filtered(nodesAndNewFilePaths, [](const std::pair &elem) { return !elem.first->filePath().equalsCaseSensitive(elem.second); }); + + // The same as above, for use when the nodes might no longer exist. + const QList> oldAndNewFilePathsFiltered + = Utils::transform(nodesAndNewFilePathsFiltered, [](const std::pair &p) { + return std::make_pair(p.first->filePath(), p.second); + }); + FilePaths renamedOnly; FilePaths failedRenamings; const auto renameFile = [&failedRenamings](const Node *node, const FilePath &newFilePath) { @@ -2560,9 +2567,9 @@ FilePairs ProjectExplorerPlugin::renameFiles( } FilePairs allRenamedFiles; - for (const std::pair &candidate : nodesAndNewFilePathsFiltered) { - if (!failedRenamings.contains(candidate.first->filePath())) - allRenamedFiles.emplaceBack(candidate.first->filePath(), candidate.second); + for (const std::pair &candidate : oldAndNewFilePathsFiltered) { + if (!failedRenamings.contains(candidate.first)) + allRenamedFiles.emplaceBack(candidate.first, candidate.second); } emit instance()->filesRenamed(allRenamedFiles); return allRenamedFiles;