forked from qt-creator/qt-creator
QmlDesigner: Fix used imports not working correctly
The existing logic (in qmljsinterpreter.cpp) for updating used imports doesn't work correctly. It takes into consideration items that are not part of the currently open document. Fixed by checking current model items in the document and updating used imports based on it. Fixes: QDS-3785 Change-Id: Ia50c3c7e7ca41b9bca0d69e7c2e253f29892933e Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -212,6 +212,7 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
|
||||
QString projectName = project ? project->displayName() : "";
|
||||
|
||||
// create import sections
|
||||
const QList<Import> usedImports = model->usedImports();
|
||||
QHash<QString, ItemLibraryImport *> importHash;
|
||||
for (const Import &import : model->imports()) {
|
||||
if (import.url() != projectName) {
|
||||
@@ -239,6 +240,7 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
|
||||
auto sectionType = isQuick3DAsset ? ItemLibraryImport::SectionType::Quick3DAssets
|
||||
: ItemLibraryImport::SectionType::Default;
|
||||
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this, sectionType);
|
||||
itemLibImport->setImportUsed(usedImports.contains(import));
|
||||
importHash.insert(importUrl, itemLibImport);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user