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