diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-08-14 15:02:59 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-08-14 15:19:19 +0300 |
commit | 51737dccd60ba7b9c21aa3f2f8e0b3af6a490c23 (patch) | |
tree | 9524c2cc38c205b8cbd18bae75209a6875fcf979 | |
parent | 4c00a8ff2cb8ea2bae15bd9246ac96870c8478a8 (diff) |
Don't create a context when it's not provided
The rest of the functions already assume that None is an empty context
-rw-r--r-- | cura/Settings/ExtruderStack.py | 14 | ||||
-rwxr-xr-x | cura/Settings/GlobalStack.py | 13 |
2 files changed, 15 insertions, 12 deletions
diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index bb35b336c7..2a9838c671 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -131,13 +131,13 @@ class ExtruderStack(CuraContainerStack): if not self._next_stack: raise Exceptions.NoGlobalStackError("Extruder {id} is missing the next stack!".format(id = self.id)) - if context is None: - context = PropertyEvaluationContext() - context.pushContainer(self) + if context: + context.pushContainer(self) if not super().getProperty(key, "settable_per_extruder", context): result = self.getNextStack().getProperty(key, property_name, context) - context.popContainer() + if context: + context.popContainer() return result limit_to_extruder = super().getProperty(key, "limit_to_extruder", context) @@ -150,13 +150,15 @@ class ExtruderStack(CuraContainerStack): try: result = self.getNextStack().extruderList[int(limit_to_extruder)].getProperty(key, property_name, context) if result is not None: - context.popContainer() + if context: + context.popContainer() return result except IndexError: pass result = super().getProperty(key, property_name, context) - context.popContainer() + if context: + context.popContainer() return result @override(CuraContainerStack) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 4528fd2302..da5a8546d3 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -192,7 +192,7 @@ class GlobalStack(CuraContainerStack): self._extruders[position] = extruder self.extrudersChanged.emit() Logger.log("i", "Extruder[%s] added to [%s] at position [%s]", extruder.id, self.id, position) - + @override(ContainerStack) def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any: """Overridden from ContainerStack @@ -211,9 +211,8 @@ class GlobalStack(CuraContainerStack): if not self.definition.findDefinitions(key = key): return None - if context is None: - context = PropertyEvaluationContext() - context.pushContainer(self) + if context: + context.pushContainer(self) # Handle the "resolve" property. #TODO: Why the hell does this involve threading? @@ -238,13 +237,15 @@ class GlobalStack(CuraContainerStack): if super().getProperty(key, "settable_per_extruder", context): result = self._extruders[str(limit_to_extruder)].getProperty(key, property_name, context) if result is not None: - context.popContainer() + if context: + context.popContainer() return result else: Logger.log("e", "Setting {setting} has limit_to_extruder but is not settable per extruder!", setting = key) result = super().getProperty(key, property_name, context) - context.popContainer() + if context: + context.popContainer() return result @override(ContainerStack) |