From 5e1bf23811cfbd971d517add2ef5b6da33402339 Mon Sep 17 00:00:00 2001 From: Vikas Pachdha Date: Tue, 23 Mar 2021 13:59:04 +0100 Subject: [PATCH] AssetExport: Fix assets not being exported in certain cases This can happen when the .ui.qml file with missing UUIDs is already open in the editor Task-number: QDS-4031 Change-Id: I17dbcf4b378141425a33dafc33a0ec47577c6d05 Reviewed-by: Thomas Hartmann --- .../qmldesigner/assetexporterplugin/assetexporter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp index 9b74b3471f1..7e0cf0d0843 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp @@ -33,6 +33,7 @@ #include "rewriterview.h" #include "qmlitemnode.h" #include "qmlobjectnode.h" +#include "coreplugin/editormanager/editormanager.h" #include "utils/qtcassert.h" #include "utils/runextensions.h" #include "variantproperty.h" @@ -307,6 +308,16 @@ void AssetExporter::preprocessQmlFile(const Utils::FilePath &path) .arg(path.toString()).arg(saver.errorString())); return; } + + // Close the document if already open. + // UUIDS are changed and editor must reopen the document, otherwise stale state of the + // document is loaded. + for (Core::IDocument *doc : Core::DocumentModel::openedDocuments()) { + if (doc->filePath() == path) { + Core::EditorManager::closeDocuments({doc}, false); + break; + } + } } // Cache component UUID