aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2023-11-20 13:36:06 +0100
committerChristian Stenger <christian.stenger@qt.io>2023-11-21 13:58:49 +0000
commit9c07e7ea7c0542928ee1a27fc21349d633b0c608 (patch)
tree337fb2c127844f9cc69ddedeb2c0c4c8002bbc4e
parent712586221278c29b9d1a5e73eeaa5b038bda7a7f (diff)
PE: Close generated files silently if they have an editor
Omits the original request whether to save a modified file if the files are opened inside QC, but it ensures to format the correct file content instead of using some cached content. Fixes: QTCREATORBUG-29904 Change-Id: I3b3f3e53fb811288a208376559243bea01d0d4a4 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
index b7207ce45e..17fc1e736c 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
@@ -11,6 +11,7 @@
#include "../projectexplorertr.h"
#include "../projecttree.h"
+#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/messagemanager.h>
@@ -351,6 +352,14 @@ void JsonWizard::accept()
return;
}
+ const QList<Core::IDocument *> documentsToClose
+ = transform(m_files, [](const GeneratorFile &file) -> Core::IDocument * {
+ if ((file.file.attributes() & Core::GeneratedFile::OpenEditorAttribute) == 0)
+ return nullptr;
+ return Core::DocumentModel::documentForFilePath(file.file.filePath());
+ });
+ Core::EditorManager::closeDocuments(documentsToClose, /*askAboutModifiedEditors=*/false);
+
emit preWriteFiles(m_files);
if (!JsonWizardGenerator::writeFiles(this, &m_files, &errorMessage)) {
if (!errorMessage.isEmpty())