Browse Source

Don't re-create user profile if one is loaded from files

The user profiles are also saved because they are added to the container registry. So if one exists for this extruder, don't create a new blank name, but use the pre-loaded one which contained the user settings the user had before he closed down Cura previously.

Contributes to issues CURA-340 and CURA-1278.
Ghostkeeper 8 years ago
parent
commit
f6ece126c3
1 changed files with 8 additions and 5 deletions
  1. 8 5
      cura/ExtruderManager.py

+ 8 - 5
cura/ExtruderManager.py

@@ -147,12 +147,15 @@ class ExtruderManager(QObject):
             self._container_stack.addContainer(self._quality)
         """
 
-        #Add an empty user profile.
-        user_profile = UM.Settings.InstanceContainer(extruder_train_id + "_current_settings")
-        user_profile.addMetaDataEntry("type", "user")
-        user_profile.setDefinition(machine_definition)
+        user_profile = container_registry.findInstanceContainers(id = extruder_train_id + "_current_settings")
+        if user_profile: #There was already a user profile, loaded from settings.
+            user_profile = user_profile[0]
+        else:
+            user_profile = UM.Settings.InstanceContainer(extruder_train_id + "_current_settings") #Add an empty user profile.
+            user_profile.addMetaDataEntry("type", "user")
+            user_profile.setDefinition(machine_definition)
+            container_registry.addContainer(user_profile)
         container_stack.addContainer(user_profile)
-        container_registry.addContainer(user_profile)
 
         container_stack.setNextStack(UM.Application.getInstance().getGlobalContainerStack())