From c049595fe328b3246854e0e99dd696dec5ce58d6 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Mon, 12 Jun 2023 11:51:07 +0200 Subject: [PATCH] Don't crash when file is not found for intent profiles CURA-9709 --- cura/Machines/Models/IntentSelectionModel.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cura/Machines/Models/IntentSelectionModel.py b/cura/Machines/Models/IntentSelectionModel.py index 1443d1427b..c239472b96 100644 --- a/cura/Machines/Models/IntentSelectionModel.py +++ b/cura/Machines/Models/IntentSelectionModel.py @@ -107,14 +107,21 @@ class IntentSelectionModel(ListModel): .findContainersMetadata(type="intent", definition=global_stack.definition.getId(), intent_category=category)[0] + intent_name = intent_metadata.get("name", category.title()) icon = intent_metadata.get("icon", None) + description = intent_metadata.get("description", None) + if icon is not None: - icon = QUrl.fromLocalFile( - Resources.getPath(cura.CuraApplication.CuraApplication.ResourceTypes.ImageFiles, icon)) + try: + icon = QUrl.fromLocalFile( + Resources.getPath(cura.CuraApplication.CuraApplication.ResourceTypes.ImageFiles, icon)) + except FileNotFoundError: + Logger.log("e", f"Icon file for intent {intent_name} not found.") + icon = None result.append({ - "name": intent_metadata.get("name", category.title()), - "description": intent_metadata.get("description", None), + "name": intent_name, + "description": description, "custom_icon": icon, "icon": None, "intent_category": category,