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.
This commit is contained in:
tetektoza
2025-05-11 14:01:38 +02:00
committed by Benjamin Nauck
parent 7d5d1c7295
commit c8395f43fc

View File

@@ -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):