From c8395f43fc0bc8debd6874d5160b01831b1fbab3 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Sun, 11 May 2025 14:01:38 +0200 Subject: [PATCH] BIM: Avoid traceback if there is no Classification selected As the title says, if user selects `OK` button and has no Classification selected (which can happen only if the list is empty I think), then they get a traceback since we're trying to access list of selections directly. So this patch adds a small patch to close the form if user has pressed `OK` button and did not select anything. --- src/Mod/BIM/bimcommands/BimClassification.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mod/BIM/bimcommands/BimClassification.py b/src/Mod/BIM/bimcommands/BimClassification.py index 8a408ead88..a858215d52 100644 --- a/src/Mod/BIM/bimcommands/BimClassification.py +++ b/src/Mod/BIM/bimcommands/BimClassification.py @@ -624,6 +624,12 @@ class BIM_Classification: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() else: + # Close the form if user has pressed Enter and did not + # select anything + if len(self.form.treeClass.selectedItems()) < 1: + self.form.close() + return + code = self.form.treeClass.selectedItems()[0].text(0) pl = self.isEditing.PropertiesList if ("StandardCode" in pl) or ("IfcClass" in pl):