Browse Source

Added more robust fault handling for preferences while loading workspace

CURA-1263
Jaime van Kessel 8 years ago
parent
commit
dcdfe612e7
1 changed files with 13 additions and 2 deletions
  1. 13 2
      plugins/3MFReader/ThreeMFWorkspaceReader.py

+ 13 - 2
plugins/3MFReader/ThreeMFWorkspaceReader.py

@@ -144,8 +144,19 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
 
         # Copy a number of settings from the temp preferences to the global
         global_preferences = Preferences.getInstance()
-        global_preferences.setValue("general/visible_settings", temp_preferences.getValue("general/visible_settings"))
-        global_preferences.setValue("cura/categories_expanded", temp_preferences.getValue("cura/categories_expanded"))
+
+        visible_settings = temp_preferences.getValue("general/visible_settings")
+        if visible_settings is None:
+            Logger.log("w", "Workspace did not contain visible settings. Leaving visibility unchanged")
+        else:
+            global_preferences.setValue("general/visible_settings", visible_settings)
+
+        categories_expanded = temp_preferences.getValue("cura/categories_expanded")
+        if categories_expanded is None:
+            Logger.log("w", "Workspace did not contain expanded categories. Leaving them unchanged")
+        else:
+            global_preferences.setValue("cura/categories_expanded", categories_expanded)
+
         Application.getInstance().expandedCategoriesChanged.emit()  # Notify the GUI of the change
 
         self._id_mapping = {}