From a5b984cbf4eac0243844e19c21481f5f062d32c1 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:53:00 +0200 Subject: [PATCH] BIM: fix BimMaterial dialog regression Fixes #24381 --- src/Mod/BIM/bimcommands/BimMaterial.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimMaterial.py b/src/Mod/BIM/bimcommands/BimMaterial.py index f57103dbc5..3fb96ecce9 100644 --- a/src/Mod/BIM/bimcommands/BimMaterial.py +++ b/src/Mod/BIM/bimcommands/BimMaterial.py @@ -76,7 +76,6 @@ class BIM_Material: self.dlg.raise_() return - self.dlg = None self.dlg = QtGui.QDialog() self.dlg.objects = [ obj @@ -195,6 +194,7 @@ class BIM_Material: context4.triggered.connect(self.onDelete) # other signal/slots to connect + self.dlg.rejected.connect(self.onReject) matList.customContextMenuRequested.connect(self.onRightClick) matList.itemDoubleClicked.connect(self.onAccept) matList.itemChanged.connect(self.onEndRename) @@ -204,7 +204,7 @@ class BIM_Material: else: # no material in the document - self.dlg = None + self.onReject() FreeCADGui.runCommand("Arch_Material") def onRightClick(self, pos): @@ -430,14 +430,12 @@ class BIM_Material: self.rescan() def onCreate(self): - if self.dlg: - self.dlg.hide() - FreeCADGui.runCommand("Arch_Material") + self.onReject() + FreeCADGui.runCommand("Arch_Material") def onMulti(self): - if self.dlg: - self.dlg.hide() - FreeCADGui.runCommand("Arch_MultiMaterial") + self.onReject() + FreeCADGui.runCommand("Arch_MultiMaterial") def onAccept(self, item=None): if self.dlg: @@ -458,13 +456,14 @@ class BIM_Material: p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM") p.SetInt("BimMaterialDialogWidth", self.dlg.width()) p.SetInt("BimMaterialDialogHeight", self.dlg.height()) - return self.onReject() + from DraftGui import todo + # delay required for matList.itemDoubleClicked action + todo.delay(self.onReject, None) def onReject(self): - if getattr(self, "dlg", None): + if self.dlg: self.dlg.hide() - del self.dlg - return True + self.dlg = None def onUpArrow(self): if self.dlg: