Browse Source

Don't read machine instances as preferences

Machine instances have the exact same file structure as preferences, except that machine instances require a name field (was already correctly implemented), but preferences didn't require it. This now forbids preferences to have a name field, so that the distinction between the two can be made.

Contributes to issue CURA-844.
Ghostkeeper 8 years ago
parent
commit
922b0df60b
1 changed files with 2 additions and 0 deletions
  1. 2 0
      plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py

+ 2 - 0
plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py

@@ -35,6 +35,8 @@ class Preferences:
             raise UM.VersionUpgrade.FormatException("No \"version\" in \"general\" section.")
         if int(self._config.get("general", "version")) != 2: # Explicitly hard-code version 2, since if this number changes the programmer MUST change this entire function.
             raise UM.VersionUpgrade.InvalidVersionException("The version of this preferences file is wrong. It must be 2.")
+        if self._config.has_option("general", "name"): #This is probably a machine instance.
+            raise UM.VersionUpgrade.FormatException("There is a \"name\" field in this configuration file. I suspect it is not a preferences file.")
 
     ##  Serialises these preferences as a preferences file of version 3.
     #