From: Youness Alaoui Date: Mon, 26 Oct 2015 19:32:08 +0000 (-0400) Subject: Do not show a dialog inside a Modal dialog X-Git-Tag: lulzbot-17.11~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=24e90204f0f62d5895863452fbd0faf9fa51cdd5;p=cura.git Do not show a dialog inside a Modal dialog This fixes T253. Showing a dialog (message box) while the main thread is locked in a ShowModal will cause X errors and a python crash. So we must delay the dialog until the modal dialog is done. --- diff --git a/Cura/gui/firmwareInstall.py b/Cura/gui/firmwareInstall.py index 60953dad..b91bfd4c 100644 --- a/Cura/gui/firmwareInstall.py +++ b/Cura/gui/firmwareInstall.py @@ -116,6 +116,7 @@ class InstallFirmwareDialog(wx.Dialog): self.Layout() self.Fit() self.success = False + self.show_connect_error_dialog = False def Run(self): if self.filename is None: @@ -127,6 +128,11 @@ class InstallFirmwareDialog(wx.Dialog): self.thread.start() self.ShowModal() + # Creating a MessageBox in a separate thread while main thread is locked inside a ShowModal + # will cause Python to crash with X errors. So we need to show the dialog here instead + if self.show_connect_dialog: + wx.MessageBox(_("Failed to find machine for firmware upgrade\nIs your machine connected to the PC?"), + _("Firmware update"), wx.OK | wx.ICON_ERROR) return self.success def OnRun(self): @@ -153,10 +159,12 @@ class InstallFirmwareDialog(wx.Dialog): programmer.connect(self.port) except ispBase.IspError: programmer.close() + if not self: + #Window destroyed + return if not programmer.isConnected(): - wx.MessageBox(_("Failed to find machine for firmware upgrade\nIs your machine connected to the PC?"), - _("Firmware update"), wx.OK | wx.ICON_ERROR) + self.show_connect_dialog = True wx.CallAfter(self.Close) return