diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-08-14 15:51:46 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-08-14 15:51:46 +0300 |
commit | 9c904f95cea9cf6f15e20111972a959326c12f03 (patch) | |
tree | e1cd70fac927dd1c05587da0de4148200160fd9b | |
parent | 51737dccd60ba7b9c21aa3f2f8e0b3af6a490c23 (diff) |
Add a cache for settable_per_extruder property
-rwxr-xr-x | cura/Settings/CuraContainerStack.py | 12 | ||||
-rwxr-xr-x | cura/Settings/GlobalStack.py | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cura/Settings/CuraContainerStack.py b/cura/Settings/CuraContainerStack.py index 4595bf3996..68371568fb 100755 --- a/cura/Settings/CuraContainerStack.py +++ b/cura/Settings/CuraContainerStack.py @@ -60,6 +60,8 @@ class CuraContainerStack(ContainerStack): import cura.CuraApplication #Here to prevent circular imports. self.setMetaDataEntry("setting_version", cura.CuraApplication.CuraApplication.SettingVersion) + self._settable_per_extruder_cache = {} + self.setDirty(False) # This is emitted whenever the containersChanged signal from the ContainerStack base class is emitted. @@ -387,6 +389,16 @@ class CuraContainerStack(ContainerStack): value = int(Application.getInstance().getMachineManager().defaultExtruderPosition) return value + def getProperty(self, key: str, property_name: str, context = None) -> Any: + if property_name == "settable_per_extruder": + # Setable per extruder isn't a value that can ever change. So once we requested it once, we can just keep + # that in memory. + if key not in self._settable_per_extruder_cache: + self._settable_per_extruder_cache[key] = super().getProperty(key, property_name, context) + return self._settable_per_extruder_cache[key] + + return super().getProperty(key, property_name, context) + class _ContainerIndexes: """Private helper class to keep track of container positions and their types.""" diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index da5a8546d3..2c7cbf5e25 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 |