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: