mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Make version upgrade also translate file names
This was required since Cura 2.1 produced files with the same filename (bar extension). This then resulted in two containers with the same ID. If you had bad luck, an instance container was chosen as global container (depending on which was first in the unordered dictionary). This gives the current settings the postfix _current_settings, fixing that issue. Contributes to issue CURA-844.
This commit is contained in:
parent
1b0974ba9f
commit
e6efba3868
4 changed files with 55 additions and 34 deletions
|
@ -66,34 +66,39 @@ class VersionUpgrade21to22(VersionUpgrade):
|
|||
## Converts machine instances from format version 1 to version 2.
|
||||
#
|
||||
# \param serialised The serialised machine instance in version 1.
|
||||
# \return The serialised machine instance in version 2, or None if the
|
||||
# input was not of the correct format.
|
||||
def upgradeMachineInstance(self, serialised):
|
||||
machine_instance = MachineInstance.importFrom(serialised)
|
||||
# \param filename The supposed file name of the machine instance.
|
||||
# \return A tuple containing the new filename and the serialised machine
|
||||
# instance in version 2, or None if the input was not of the correct
|
||||
# format.
|
||||
def upgradeMachineInstance(self, serialised, filename):
|
||||
machine_instance = MachineInstance.importFrom(serialised, filename)
|
||||
if not machine_instance: #Invalid file format.
|
||||
return None
|
||||
return filename, None
|
||||
return machine_instance.export()
|
||||
|
||||
## Converts preferences from format version 2 to version 3.
|
||||
#
|
||||
# \param serialised The serialised preferences file in version 2.
|
||||
# \return The serialised preferences in version 3, or None if the input
|
||||
# was not of the correct format.
|
||||
def upgradePreferences(self, serialised):
|
||||
preferences = Preferences.importFrom(serialised)
|
||||
# \param filename THe supposed file name of the preferences file.
|
||||
# \return A tuple containing the new filename and the serialised
|
||||
# preferences in version 3, or None if the input was not of the correct
|
||||
# format.
|
||||
def upgradePreferences(self, serialised, filename):
|
||||
preferences = Preferences.importFrom(serialised, filename)
|
||||
if not preferences: #Invalid file format.
|
||||
return None
|
||||
return filename, None
|
||||
return preferences.export()
|
||||
|
||||
## Converts profiles from format version 1 to version 2.
|
||||
#
|
||||
# \param serialised The serialised profile in version 1.
|
||||
# \return The serialised profile in version 2, or None if the input was
|
||||
# not of the correct format.
|
||||
def upgradeProfile(self, serialised):
|
||||
profile = Profile.importFrom(serialised)
|
||||
# \param filename The supposed file name of the profile.
|
||||
# \return A tuple containing the new filename and the serialised profile
|
||||
# in version 2, or None if the input was not of the correct format.
|
||||
def upgradeProfile(self, serialised, filename):
|
||||
profile = Profile.importFrom(serialised, filename)
|
||||
if not profile: # Invalid file format.
|
||||
return None
|
||||
return filename, None
|
||||
return profile.export()
|
||||
|
||||
## Translates a printer name that might have changed since the last
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue