Browse Source

Fix importing legacy INI quality profiles

CURA-4876
Lipu Fei 7 years ago
parent
commit
63ac8412e6
1 changed files with 8 additions and 1 deletions
  1. 8 1
      plugins/LegacyProfileReader/LegacyProfileReader.py

+ 8 - 1
plugins/LegacyProfileReader/LegacyProfileReader.py

@@ -125,7 +125,10 @@ class LegacyProfileReader(ProfileReader):
             Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?")
             return None
         current_printer_definition = global_container_stack.definition
-        profile.setDefinition(current_printer_definition.getId())
+        quality_definition = current_printer_definition.getMetaDataEntry("quality_definition")
+        if not quality_definition:
+            quality_definition = current_printer_definition.getId()
+        profile.setDefinition(quality_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]
             compiled = compile(old_setting_expression, new_setting, "eval")
@@ -162,6 +165,10 @@ class LegacyProfileReader(ProfileReader):
         data = stream.getvalue()
         profile.deserialize(data)
 
+        # The definition can get reset to fdmprinter during the deserialization's upgrade. Here we set the definition
+        # again.
+        profile.setDefinition(quality_definition)
+
         #We need to return one extruder stack and one global stack.
         global_container_id = container_registry.uniqueName("Global Imported Legacy Profile")
         global_profile = profile.duplicate(new_id = global_container_id, new_name = profile_id) #Needs to have the same name as the extruder profile.