mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 08:14:22 +08: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
@ -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):
|
||||||
is_new_material = False
|
new_material = ContainerRegistry.getInstance().findContainers(id = new_material_id)[0]
|
||||||
if found_materials:
|
is_new_material = False
|
||||||
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):
|
||||||
is_new_material = False
|
new_hotend_material = ContainerRegistry.getInstance().findContainers(id = new_hotend_id)[0]
|
||||||
if found_materials:
|
is_new_material = False
|
||||||
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…
x
Reference in New Issue
Block a user