Use getNumInstances instead of counting the number of instances in machinemanager

This should prevent having to initiate the cached values if we only want to know the number of settings.
This commit is contained in:
Jaime van Kessel 2019-01-02 09:39:44 +01:00
parent e8febaff59
commit 2a4c66888e

View file

@ -436,12 +436,12 @@ class MachineManager(QObject):
if not self._global_container_stack:
return False
if self._global_container_stack.getTop().findInstances():
if self._global_container_stack.getTop().getNumInstances() != 0:
return True
stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
for stack in stacks:
if stack.getTop().findInstances():
if stack.getTop().getNumInstances() != 0:
return True
return False
@ -451,10 +451,10 @@ class MachineManager(QObject):
if not self._global_container_stack:
return 0
num_user_settings = 0
num_user_settings += len(self._global_container_stack.getTop().findInstances())
stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
num_user_settings += self._global_container_stack.getTop().getNumInstances()
stacks = self._global_container_stack.extruderList
for stack in stacks:
num_user_settings += len(stack.getTop().findInstances())
num_user_settings += stack.getTop().getNumInstances()
return num_user_settings
## Delete a user setting from the global stack and all extruder stacks.