From ccf0a68c42875f5c5d6bbf4d128e315f48f3e03b Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Thu, 25 Apr 2024 18:36:24 +0300 Subject: 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 Reviewed-by: Miikka Heikkinen --- .../components/contentlibrary/contentlibrarymaterialsmodel.cpp | 3 +++ .../components/contentlibrary/contentlibrarymaterialsmodel.h | 1 + .../components/contentlibrary/contentlibraryview.cpp | 10 +++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.cpp index 26747d359cd..dd032a6d1fa 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.cpp @@ -40,7 +40,10 @@ ContentLibraryMaterialsModel::ContentLibraryMaterialsModel(ContentLibraryWidget qmlRegisterType("WebFetcher", 1, 0, "FileDownloader"); qmlRegisterType("WebFetcher", 1, 0, "MultiFileDownloader"); +} +void ContentLibraryMaterialsModel::loadBundle() +{ QDir bundleDir{m_downloadPath}; if (fetchBundleMetadata(bundleDir) && fetchBundleIcons(bundleDir)) loadMaterialBundle(bundleDir); diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.h index 21bd3741375..a2c2e90ce1e 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.h +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterialsmodel.h @@ -51,6 +51,7 @@ public: void resetModel(); void updateIsEmpty(); + void loadBundle(); Internal::ContentLibraryBundleImporter *bundleImporter() const; diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp index 1e0b69099be..9cbc0f73393 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp @@ -290,7 +290,6 @@ void ContentLibraryView::modelAttached(Model *model) m_hasQuick3DImport = model->hasImport("QtQuick3D"); updateBundlesQuick3DVersion(); - updateBundleMaterialsImportedState(); const bool hasLibrary = Utils3D::materialLibraryNode(this).isValid(); m_widget->setHasMaterialLibrary(hasLibrary); @@ -302,11 +301,16 @@ void ContentLibraryView::modelAttached(Model *model) m_widget->setHasActive3DScene(m_sceneId != -1); 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(); - updateBundleEffectsImportedState(); - m_widget->userModel()->loadMaterialBundle(); m_widget->userModel()->loadTextureBundle(); + + updateBundleMaterialsImportedState(); + updateBundleEffectsImportedState(); + updateBundleUserMaterialsImportedState(); } void ContentLibraryView::modelAboutToBeDetached(Model *model) -- cgit v1.2.3