Browse Source

Cache global container stack

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

Contributes to issue CURA-2785.
Ghostkeeper 8 years ago
parent
commit
06521d7c49
1 changed files with 3 additions and 2 deletions
  1. 3 2
      plugins/LegacyProfileReader/LegacyProfileReader.py

+ 3 - 2
plugins/LegacyProfileReader/LegacyProfileReader.py

@@ -66,8 +66,9 @@ class LegacyProfileReader(ProfileReader):
     def read(self, file_name):
     def read(self, file_name):
         if file_name.split(".")[-1] != "ini":
         if file_name.split(".")[-1] != "ini":
             return None
             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:
         if multi_extrusion:
             Logger.log("e", "Unable to import legacy profile %s. Multi extrusion is not supported", file_name)
             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")
             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:
         if "translation" not in dict_of_doom:
             Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?")
             Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?")
             return None
             return None
-        current_printer_definition = Application.getInstance().getGlobalContainerStack().getBottom()
+        current_printer_definition = global_container_stack.getBottom()
         profile.setDefinition(current_printer_definition)
         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.
         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]
             old_setting_expression = dict_of_doom["translation"][new_setting]