From 06715441d695064e0548fa94d0cc3e325a3870a6 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 27 Jun 2022 09:26:19 +0200 Subject: [PATCH] Fix "save as" with same file path, involving symbolic links We close all existing documents for the new file path, before renaming the current document, but may not close the current document itself. We already tried to prevent that, but didn't take symbolic links into account (which could also involve directories that are symbolic links). Use the same logic for determining if the two files are "the same" as in DocumentModel::documentForFilePath. Fixes: QTCREATORBUG-27741 Change-Id: I3f3984f1f761328ee373b34870e03a9fce30c190 Reviewed-by: David Schulz --- src/plugins/coreplugin/editormanager/editormanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index dbd4edd7fc3..4fc365496b7 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -2533,7 +2533,8 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document) if (absoluteFilePath.isEmpty()) return false; - if (absoluteFilePath != document->filePath()) { + if (DocumentManager::filePathKey(absoluteFilePath, DocumentManager::ResolveLinks) + != DocumentManager::filePathKey(document->filePath(), DocumentManager::ResolveLinks)) { // close existing editors for the new file name IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath); if (otherDocument)