From 922b0df60bdb68e7871c90dd79df3d9108ea95a6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 30 Jun 2016 14:21:07 +0200 Subject: [PATCH] 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. --- plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py index 87077b1fde..961f4f963e 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py +++ b/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. #