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): ...@@ -1285,6 +1285,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if len(target): if len(target):
self.recvlisteners+=[self.waitforsdresponse] self.recvlisteners+=[self.waitforsdresponse]
self.p.send_now("M23 "+target.lower()) self.p.send_now("M23 "+target.lower())
dlg.Destroy()
#print self.sdfiles #print self.sdfiles
def getfiles(self): def getfiles(self):
...@@ -1368,6 +1369,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1368,6 +1369,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
basedir = os.path.split(self.filename)[0] basedir = os.path.split(self.filename)[0]
except: except:
pass pass
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 = 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.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 or dlg.ShowModal() == wx.ID_OK):
...@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
name = dlg.GetPath() name = dlg.GetPath()
if not(os.path.exists(name)): if not(os.path.exists(name)):
self.status.SetStatusText(_("File not found!")) self.status.SetStatusText(_("File not found!"))
if dlg is not None:
dlg.Destroy()
return return
path = os.path.split(name)[0] path = os.path.split(name)[0]
if path != self.settings.last_file_path: if path != self.settings.last_file_path:
...@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
threading.Thread(target = self.loadviz).start() threading.Thread(target = self.loadviz).start()
if dlg is not None:
dlg.Destroy()
def loadviz(self): def loadviz(self):
gcode = self.fgcode gcode = self.fgcode
...@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.send_now("M21") self.p.send_now("M21")
self.p.send_now("M28 "+str(dlg.GetValue())) self.p.send_now("M28 "+str(dlg.GetValue()))
self.recvlisteners+=[self.uploadtrigger] self.recvlisteners+=[self.uploadtrigger]
dlg.Destroy()
def pause(self, event): def pause(self, event):
print _("Paused.") print _("Paused.")
...@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.paused = 0 self.p.paused = 0
wx.CallAfter(self.pausebtn.SetLabel, _("Pause")) wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
self.paused = 0 self.paused = 0
dlg.Destroy()
class PronterApp(wx.App): 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