From a41c4de3df3cd120095da646e656597e10f6e3bf Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 21 Jun 2024 12:05:30 +0200 Subject: [PATCH] CMakePM: Do not hang on renaming files in parent directories This fixes renaming of "my/class.cpp my/class.h" via "../class.h" and resulting into "class.cpp class.h". "oldRelPathName" was not needed since it was saved in the "m_filesToBeRenamed" map and it was computed from the new filename. This was prone to error. Task-number: QTCREATORBUG-30830 Change-Id: I839fab3bd6a6172f5ebfbaf9a4b6501cd5693fa8 Reviewed-by: Alessandro Portale --- src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index e0d2b6773fb..f1c3731d4f2 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -936,10 +936,6 @@ bool CMakeBuildSystem::renameFile(Node *context, const FilePath newRelPath = newFilePath.canonicalPath().relativePathFrom(projDir).cleanPath(); const QString newRelPathName = newRelPath.toString(); - // FilePath needs the file to exist on disk, the old file has already been renamed - const QString oldRelPathName - = newRelPath.parentDir().pathAppended(oldFilePath.fileName()).cleanPath().toString(); - const QString targetName = n->buildKey(); const QString key = QStringList{projDir.path(), targetName, oldFilePath.path(), newFilePath.path()}.join( @@ -984,7 +980,7 @@ bool CMakeBuildSystem::renameFile(Node *context, } // Try the next occurrence. This can happen if set_source_file_properties is used - fileToRename = projectFileArgumentPosition(targetName, oldRelPathName); + fileToRename = projectFileArgumentPosition(targetName, fileToRename->relativeFileName); } while (fileToRename && !fileToRename->fromGlobbing); return true;