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 <thomas.hartmann@qt.io>
This commit is contained in:
Vikas Pachdha
2021-03-23 13:59:04 +01:00
parent ef508d61ad
commit 5e1bf23811

View File

@@ -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