mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Use isLoaded to check if a material is already loaded
This prevents us from having to make an expensive findContainers call if it's not necessary, and also prevents us from unnecessarily loading the subcontainers in a loop during loading. Contributes to issue CURA-4243.
This commit is contained in:
parent
cacc4b8586
commit
c34de83e3f
1 changed files with 6 additions and 8 deletions
|
@ -550,10 +550,9 @@ class XmlMaterialProfile(InstanceContainer):
|
||||||
# project file and the a material in Cura have the same ID.
|
# project file and the a material in Cura have the same ID.
|
||||||
# In the case if a derived material already exists, override that material container because if
|
# In the case if a derived material already exists, override that material container because if
|
||||||
# the data in the parent material has been changed, the derived ones should be updated too.
|
# the data in the parent material has been changed, the derived ones should be updated too.
|
||||||
found_materials = ContainerRegistry.getInstance().findInstanceContainers(id = new_material_id)
|
if ContainerRegistry.getInstance().isLoaded(new_material_id):
|
||||||
|
new_material = ContainerRegistry.getInstance().findContainers(id = new_material_id)[0]
|
||||||
is_new_material = False
|
is_new_material = False
|
||||||
if found_materials:
|
|
||||||
new_material = found_materials[0]
|
|
||||||
else:
|
else:
|
||||||
new_material = XmlMaterialProfile(new_material_id)
|
new_material = XmlMaterialProfile(new_material_id)
|
||||||
is_new_material = True
|
is_new_material = True
|
||||||
|
@ -605,10 +604,9 @@ class XmlMaterialProfile(InstanceContainer):
|
||||||
|
|
||||||
# Same as machine compatibility, keep the derived material containers consistent with the parent
|
# Same as machine compatibility, keep the derived material containers consistent with the parent
|
||||||
# material
|
# material
|
||||||
found_materials = ContainerRegistry.getInstance().findInstanceContainers(id = new_hotend_id)
|
if ContainerRegistry.getInstance().isLoaded(new_hotend_id):
|
||||||
|
new_hotend_material = ContainerRegistry.getInstance().findContainers(id = new_hotend_id)[0]
|
||||||
is_new_material = False
|
is_new_material = False
|
||||||
if found_materials:
|
|
||||||
new_hotend_material = found_materials[0]
|
|
||||||
else:
|
else:
|
||||||
new_hotend_material = XmlMaterialProfile(new_hotend_id)
|
new_hotend_material = XmlMaterialProfile(new_hotend_id)
|
||||||
is_new_material = True
|
is_new_material = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue