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.
This commit is contained in:
Ghostkeeper 2016-08-09 15:25:17 +02:00
parent 71505a8b35
commit 36b027b290
No known key found for this signature in database
GPG key ID: 701948C5954A7385

View file

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