Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2020-07-13 12:45:16 +0300
committerGhostkeeper <rubend@tutanota.com>2020-07-13 12:45:16 +0300
commit4372099e1d401a33f1b2adee8801386dbfb2e6e2 (patch)
tree55bbb9143c79f99469a505b3abb8372db6c42c3d
parente010d4f945c62967cf5ebee9eedd64b74970b6e5 (diff)
Don't crash if material preferences are corrupt
This time we don't need to catch permission errors and such since we're reading it from a string that was stored in memory (read when the preferences file was read). However we do need to catch JSON Decoding Errors since the JSON syntax might be broken by the user modifying these files or because the file wasn't saved properly before. Fixes Sentry issue CURA-112.
-rw-r--r--cura/UI/PrintInformation.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cura/UI/PrintInformation.py b/cura/UI/PrintInformation.py
index ae4aab0407..22710165b3 100644
--- a/cura/UI/PrintInformation.py
+++ b/cura/UI/PrintInformation.py
@@ -202,7 +202,11 @@ class PrintInformation(QObject):
self._material_costs[build_plate_number] = []
self._material_names[build_plate_number] = []
- material_preference_values = json.loads(self._application.getInstance().getPreferences().getValue("cura/material_settings"))
+ try:
+ material_preference_values = json.loads(self._application.getInstance().getPreferences().getValue("cura/material_settings"))
+ except json.JSONDecodeError:
+ Logger.warning("Material preference values are corrupt. Will revert to defaults!")
+ material_preference_values = {}
for index, extruder_stack in enumerate(global_stack.extruderList):
if index >= len(self._material_amounts):