Skip global stacks better

Otherwise it wouldn't skip custom-defined stacks, such as the PPA's stack class.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-26 17:11:22 +02:00
parent 60939d220b
commit 557c3d9515
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276

View File

@ -3,12 +3,11 @@
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry # To listen to containers being added.
from UM.Settings.DefinitionContainer import DefinitionContainer
from UM.Settings.Interfaces import ContainerInterface
from UM.Signal import Signal
import cura.CuraApplication # Imported like this to prevent circular dependencies.
from cura.Machines.MachineNode import MachineNode
from cura.Settings.ExtruderStack import ExtruderStack # To skip extruder stacks being added.
from cura.Settings.GlobalStack import GlobalStack # To listen only to global stacks being added.
from typing import Dict, TYPE_CHECKING
import time
@ -64,7 +63,7 @@ class ContainerTree:
start_time = time.time()
all_stacks = ContainerRegistry.getInstance().findContainerStacks()
for stack in all_stacks:
if isinstance(stack, ExtruderStack):
if not isinstance(stack, GlobalStack):
continue # Only want to load global stacks. We don't need to create a tree for extruder definitions.
definition_id = stack.definition.getId()
if definition_id not in self.machines:
@ -76,12 +75,10 @@ class ContainerTree:
Logger.log("d", "Building the container tree took %s seconds", time.time() - start_time)
## When a printer gets added, we need to build up the tree for that container.
def _machineAdded(self, definition_container: ContainerInterface):
if not isinstance(definition_container, DefinitionContainer):
def _machineAdded(self, container_stack: ContainerInterface):
if not isinstance(container_stack, GlobalStack):
return # Not our concern.
if definition_container.getMetaDataEntry("position") is not None:
return # This is an extruder definition. Not our concern.
definition_id = definition_container.getId()
definition_id = container_stack.definition.getId()
if definition_id in self.machines:
return # Already have this definition ID.