Commit a6848356 authored by Kliment Yanev's avatar Kliment Yanev

Ensure dialogs are destroyed whether they are shown or not.

Files opened from command line would create a dialog but never display it, keeping a handle to it open. This interacted with a strange wx bug to cause a hard crash if a file in the same directory as the active directory of the dialog was edited with vim. This commit should prevent these crashes.
parent 64326315
......@@ -1285,6 +1285,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if len(target):
self.recvlisteners+=[self.waitforsdresponse]
self.p.send_now("M23 "+target.lower())
dlg.Destroy()
#print self.sdfiles
def getfiles(self):
......@@ -1368,8 +1369,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
basedir = os.path.split(self.filename)[0]
except:
pass
dlg = wx.FileDialog(self, _("Open file to print"), basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
dlg=None
if filename is None:
dlg = wx.FileDialog(self, _("Open file to print"), basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
if(filename is not None or dlg.ShowModal() == wx.ID_OK):
if filename is not None:
name = filename
......@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
name = dlg.GetPath()
if not(os.path.exists(name)):
self.status.SetStatusText(_("File not found!"))
if dlg is not None:
dlg.Destroy()
return
path = os.path.split(name)[0]
if path != self.settings.last_file_path:
......@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if self.p.online:
wx.CallAfter(self.printbtn.Enable)
threading.Thread(target = self.loadviz).start()
if dlg is not None:
dlg.Destroy()
def loadviz(self):
gcode = self.fgcode
......@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.send_now("M21")
self.p.send_now("M28 "+str(dlg.GetValue()))
self.recvlisteners+=[self.uploadtrigger]
dlg.Destroy()
def pause(self, event):
print _("Paused.")
......@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.paused = 0
wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
self.paused = 0
dlg.Destroy()
class PronterApp(wx.App):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment