Просмотр исходного кода

Fix copying ConfigParser

Turns out that copy.copy() doesn't work on ConfigParsers. It returns a different instance but modifying that instance still modifies the old configs. Deep copy isn't allowed. But this dictionary copy works.

Contributes to issue CURA-844.
Ghostkeeper 8 лет назад
Родитель
Сommit
36b027b290
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py

+ 2 - 2
plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py

@@ -2,7 +2,6 @@
 # Cura is released under the terms of the AGPLv3 or higher.
 
 import configparser #To read config files.
-import copy #To split config files into multiple config files.
 import io #To write config files to strings as if they were files.
 
 import UM.VersionUpgrade
@@ -146,7 +145,8 @@ class Profile:
             #Split this profile into multiple profiles, one for each material.
             for material_id in _new_materials:
                 filenames.append("{profile}_{material}".format(profile = self._filename, material = material_id))
-                config_copy = copy.copy(config)
+                config_copy = configparser.ConfigParser(interpolation = None)
+                config_copy.read_dict(config) #Copy the config to a new ConfigParser instance.
                 config_copy.set("metadata", "material", material_id)
                 configs.append(config_copy)
         else: