QmlDesigner: Fix bundle material instance not removed

after removing a bundle material from project

Fixes: QDS-12527
Change-Id: I72b4d99d15a6fbd454d45bdf0ba1a1b469e1a5bb
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-04-25 18:36:24 +03:00
parent 17a28ea850
commit ccf0a68c42
3 changed files with 11 additions and 3 deletions

View File

@@ -40,7 +40,10 @@ ContentLibraryMaterialsModel::ContentLibraryMaterialsModel(ContentLibraryWidget
qmlRegisterType<QmlDesigner::FileDownloader>("WebFetcher", 1, 0, "FileDownloader"); qmlRegisterType<QmlDesigner::FileDownloader>("WebFetcher", 1, 0, "FileDownloader");
qmlRegisterType<QmlDesigner::MultiFileDownloader>("WebFetcher", 1, 0, "MultiFileDownloader"); qmlRegisterType<QmlDesigner::MultiFileDownloader>("WebFetcher", 1, 0, "MultiFileDownloader");
}
void ContentLibraryMaterialsModel::loadBundle()
{
QDir bundleDir{m_downloadPath}; QDir bundleDir{m_downloadPath};
if (fetchBundleMetadata(bundleDir) && fetchBundleIcons(bundleDir)) if (fetchBundleMetadata(bundleDir) && fetchBundleIcons(bundleDir))
loadMaterialBundle(bundleDir); loadMaterialBundle(bundleDir);

View File

@@ -51,6 +51,7 @@ public:
void resetModel(); void resetModel();
void updateIsEmpty(); void updateIsEmpty();
void loadBundle();
Internal::ContentLibraryBundleImporter *bundleImporter() const; Internal::ContentLibraryBundleImporter *bundleImporter() const;

View File

@@ -290,7 +290,6 @@ void ContentLibraryView::modelAttached(Model *model)
m_hasQuick3DImport = model->hasImport("QtQuick3D"); m_hasQuick3DImport = model->hasImport("QtQuick3D");
updateBundlesQuick3DVersion(); updateBundlesQuick3DVersion();
updateBundleMaterialsImportedState();
const bool hasLibrary = Utils3D::materialLibraryNode(this).isValid(); const bool hasLibrary = Utils3D::materialLibraryNode(this).isValid();
m_widget->setHasMaterialLibrary(hasLibrary); m_widget->setHasMaterialLibrary(hasLibrary);
@@ -302,11 +301,16 @@ void ContentLibraryView::modelAttached(Model *model)
m_widget->setHasActive3DScene(m_sceneId != -1); m_widget->setHasActive3DScene(m_sceneId != -1);
m_widget->clearSearchFilter(); m_widget->clearSearchFilter();
// bundles loading has to happen here, otherwise project path is not ready which will
// cause bundle items types to resolve incorrectly
m_widget->materialsModel()->loadBundle();
m_widget->effectsModel()->loadBundle(); m_widget->effectsModel()->loadBundle();
updateBundleEffectsImportedState();
m_widget->userModel()->loadMaterialBundle(); m_widget->userModel()->loadMaterialBundle();
m_widget->userModel()->loadTextureBundle(); m_widget->userModel()->loadTextureBundle();
updateBundleMaterialsImportedState();
updateBundleEffectsImportedState();
updateBundleUserMaterialsImportedState();
} }
void ContentLibraryView::modelAboutToBeDetached(Model *model) void ContentLibraryView::modelAboutToBeDetached(Model *model)