From 06521d7c49c83ea3d77cd996528e90b12eeef50f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 25 Oct 2016 13:16:41 +0200 Subject: [PATCH] Cache global container stack We'll need it multiple times. Could be a bit faster. Contributes to issue CURA-2785. --- plugins/LegacyProfileReader/LegacyProfileReader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 5105bf71da..96a9d96902 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -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]