From 4372099e1d401a33f1b2adee8801386dbfb2e6e2 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Jul 2020 11:45:16 +0200 Subject: [PATCH 1/2] 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. --- cura/UI/PrintInformation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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): From c38ee8a365732ade527e7a89883b53974ff4f70e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 13 Jul 2020 13:47:51 +0200 Subject: [PATCH 2/2] Clear focus when changing tools This is a fix for a bug on MacOS where the delete key wasn't working. A text field from the tools was in focus, which caught the key event, preventing objects from being deleted. Fixes #7754 and CURA-7585. --- resources/qml/Toolbar.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 0bf09b4d18..89d64b06ad 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -78,6 +78,10 @@ Item { base.activeY = y; } + //Clear focus when tools change. This prevents the tool grabbing focus when activated. + //Grabbing focus prevents items from being deleted. + //Apparently this was only a problem on MacOS. + forceActiveFocus(); } //Workaround since using ToolButton's onClicked would break the binding of the checked property, instead