forked from qt-creator/qt-creator
QmlDesigner: Clear material preview cache on detach
The previews are cached based on modelnode internal id, which can overlap between documents, resulting in briefly showing incorrect preview when new document is opened. Also, never clearing the cache leads to leaking memory. Fixed the issue by clearing the preview cache whenever all materials are removed from browser (model detach and material library deletion). Change-Id: Idad39fef62871c4e94f35604e643c7195ae9ec81 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -212,6 +212,7 @@ bool MaterialBrowserView::isTexture(const ModelNode &node) const
|
||||
void MaterialBrowserView::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
m_widget->materialBrowserModel()->setMaterials({}, m_hasQuick3DImport);
|
||||
m_widget->clearPreviewCache();
|
||||
|
||||
if (m_propertyGroupsLoaded) {
|
||||
m_propertyGroupsLoaded = false;
|
||||
@@ -301,6 +302,7 @@ void MaterialBrowserView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
// removing the material editor node
|
||||
if (removedNode.id() == Constants::MATERIAL_LIB_ID) {
|
||||
m_widget->materialBrowserModel()->setMaterials({}, m_hasQuick3DImport);
|
||||
m_widget->clearPreviewCache();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user