Check if a material is being used based on base_file

CURA-4129
This commit is contained in:
Lipu Fei 2017-08-14 08:48:07 +02:00
parent 0b19b20c24
commit bb1316fc88

View file

@ -333,16 +333,15 @@ class ContainerManager(QObject):
@pyqtSlot(str, result = bool) @pyqtSlot(str, result = bool)
def isContainerUsed(self, container_id): def isContainerUsed(self, container_id):
Logger.log("d", "Checking if container %s is currently used", container_id) Logger.log("d", "Checking if container %s is currently used", container_id)
# check if this is a material container. If so, check if any material with the same GUID is being used by any # check if this is a material container. If so, check if any material with the same base is being used by any
# stacks. # stacks.
container_ids_to_check = [container_id] container_ids_to_check = [container_id]
container_results = self._container_registry.findInstanceContainers(id = container_id, type = "material") container_results = self._container_registry.findInstanceContainers(id = container_id, type = "material")
if container_results: if container_results:
this_container = container_results[0] this_container = container_results[0]
container_guid = this_container.getMetaDataEntry("GUID") material_base_file = this_container.getMetaDataEntry("base_file", this_container.getId())
# check all material container IDs with the same GUID # check all material container IDs with the same base
material_containers = self._container_registry.findInstanceContainers(id = container_id, material_containers = self._container_registry.findInstanceContainers(base_file = material_base_file,
GUID = container_guid,
type = "material") type = "material")
if material_containers: if material_containers:
container_ids_to_check = [container.getId() for container in material_containers] container_ids_to_check = [container.getId() for container in material_containers]