From b024ebda0e6d19aa01f37e77ebf90e6fde8dcf8c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 25 Apr 2023 12:59:05 +0200 Subject: [PATCH] ProjectExplorer: Support moving to different dir when renaming ... files in the project tree. Fixes: QTCREATORBUG-15981 Change-Id: Id704ec0638046e2191638b59e0a597b984d4822a Reviewed-by: Christian Stenger Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: Eike Ziller --- src/plugins/coreplugin/fileutils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index a48cd34da70..c98d5269f1c 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -170,8 +170,11 @@ bool FileUtils::renameFile(const FilePath &orgFilePath, const FilePath &newFileP if (orgFilePath == newFilePath) return false; - FilePath dir = orgFilePath.absolutePath(); + const FilePath dir = orgFilePath.absolutePath(); IVersionControl *vc = VcsManager::findVersionControlForDirectory(dir); + const FilePath newDir = newFilePath.absolutePath(); + if (newDir != dir && !newDir.ensureWritableDir()) + return false; bool result = false; if (vc && vc->supportsOperation(IVersionControl::MoveOperation))