Remove _added functions for nodes that can't be added during runtime

Among the machines, variants, materials, qualities and intents, only machines and materials can ever be added during runtime. For the rest, we don't need to listen to these signals.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-16 16:28:42 +02:00
parent 97e77994a1
commit 80baeb9873
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
6 changed files with 7 additions and 188 deletions

View file

@ -4,7 +4,6 @@
from typing import Union, TYPE_CHECKING
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.Interfaces import ContainerInterface
from cura.Machines.ContainerNode import ContainerNode
from cura.Machines.IntentNode import IntentNode
@ -21,7 +20,6 @@ class QualityNode(ContainerNode):
super().__init__(container_id)
self.parent = parent
self.intents = {} # type: Dict[str, IntentNode]
ContainerRegistry.getInstance().containerAdded.connect(self._intentAdded)
self._loadAll()
def _loadAll(self) -> None:
@ -31,21 +29,4 @@ class QualityNode(ContainerNode):
if not isinstance(self.parent, MachineNode): # Not a global profile.
for intent in container_registry.findInstanceContainersMetadata(type = "intent", definition = self.parent.variant.machine.quality_definition, variant = self.parent.variant.variant_name, material = self.parent.base_file):
self.intents[intent["id"]] = IntentNode(intent["id"], quality = self)
# Otherwise, there are no intents for global profiles.
def _intentAdded(self, container: ContainerInterface) -> None:
from cura.Machines.MachineNode import MachineNode # Imported here to prevent circular imports.
if container.getMetaDataEntry("type") != "intent":
return # Not interested if it's not an intent.
if isinstance(self.parent, MachineNode):
return # Global profiles don't have intents.
if container.getMetaDataEntry("definition") != self.parent.variant.machine.quality_definition:
return # Incorrect printer.
if container.getMetaDataEntry("variant") != self.parent.variant.variant_name:
return # Incorrect variant.
if container.getMetaDataEntry("material") != self.parent.base_file:
return # Incorrect material.
container_id = container.getId()
if container_id in self.intents:
return # Already have this.
self.intents[container_id] = IntentNode(container_id, quality = self)
# Otherwise, there are no intents for global profiles.