Cache global container stack

We'll need it multiple times. Could be a bit faster.

Contributes to issue CURA-2785.
This commit is contained in:
Ghostkeeper 2016-10-25 13:16:41 +02:00
parent 35f43df2f6
commit 06521d7c49
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75

View File

@ -66,8 +66,9 @@ class LegacyProfileReader(ProfileReader):
def read(self, file_name):
if file_name.split(".")[-1] != "ini":
return None
global_container_stack = Application.getInstance().getGlobalContainerStack()
multi_extrusion = Application.getInstance().getGlobalContainerStack().getProperty("machine_extruder_count", "value") > 1
multi_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
if multi_extrusion:
Logger.log("e", "Unable to import legacy profile %s. Multi extrusion is not supported", file_name)
raise Exception("Unable to import legacy profile. Multi extrusion is not supported")
@ -117,7 +118,7 @@ class LegacyProfileReader(ProfileReader):
if "translation" not in dict_of_doom:
Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?")
return None
current_printer_definition = Application.getInstance().getGlobalContainerStack().getBottom()
current_printer_definition = global_container_stack.getBottom()
profile.setDefinition(current_printer_definition)
for new_setting in dict_of_doom["translation"]: #Evaluate all new settings that would get a value from the translations.
old_setting_expression = dict_of_doom["translation"][new_setting]