Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2020-08-14 15:51:46 +0300
committerJaime van Kessel <nallath@gmail.com>2020-08-14 15:51:46 +0300
commit9c904f95cea9cf6f15e20111972a959326c12f03 (patch)
treee1cd70fac927dd1c05587da0de4148200160fd9b
parent51737dccd60ba7b9c21aa3f2f8e0b3af6a490c23 (diff)
Add a cache for settable_per_extruder property
-rwxr-xr-xcura/Settings/CuraContainerStack.py12
-rwxr-xr-xcura/Settings/GlobalStack.py2
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