forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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())
|
||||
|
Reference in New Issue
Block a user