From: Youness Alaoui Date: Tue, 7 Jul 2015 19:48:07 +0000 (-0400) Subject: Prevent multiple calls to afterSplashCallback X-Git-Tag: lulzbot-15.02.1-2.01~64 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=08c5f2133c9dbc8b986bc727c0b9768d9e45ccfd;p=cura.git Prevent multiple calls to afterSplashCallback This fixes issue #133. Problem was that if splash.OnClose was called before the afterSplashCallback was done (such as, if it's blocking on a configWizard), then the callback would be called again. This also fixes a segmentation fault if you cancel the initial config wizard by making sure the callback is done outside the event thread and splash destruction is done at the proper time and from the proper thread. --- diff --git a/Cura/gui/app.py b/Cura/gui/app.py index 8f4fb003..3caf494f 100644 --- a/Cura/gui/app.py +++ b/Cura/gui/app.py @@ -99,6 +99,12 @@ class CuraApp(wx.App): except: pass + def destroySplashScreen(self): + if self.splash is not None: + self.splash.Show(False) + self.splash.Destroy() + self.splash = None + def afterSplashCallback(self): #These imports take most of the time and thus should be done after showing the splashscreen import webbrowser @@ -134,26 +140,20 @@ class CuraApp(wx.App): exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'Rocktopus.stl')) self.loadFiles = [exampleFile] - if self.splash is not None: - self.splash.Show(False) - self.splash = None + self.destroySplashScreen() configWizard.ConfigWizard() if profile.getPreference('check_for_updates') == 'True': newVersion = version.checkForNewerVersion() if newVersion is not None: - if self.splash is not None: - self.splash.Show(False) - self.splash = None + self.destroySplashScreen() if wx.MessageBox(_("A new version of Cura is available, would you like to download?"), _("New version available"), wx.YES_NO | wx.ICON_INFORMATION) == wx.YES: webbrowser.open(newVersion) return if profile.getMachineSetting('machine_name') == '': return self.mainWindow = mainWindow.mainWindow() - if self.splash is not None: - self.splash.Show(False) - self.splash = None + self.destroySplashScreen() self.SetTopWindow(self.mainWindow) self.mainWindow.Show() self.mainWindow.OnDropFiles(self.loadFiles) diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py index 44bad77a..a3568a0d 100644 --- a/Cura/gui/splashScreen.py +++ b/Cura/gui/splashScreen.py @@ -14,13 +14,13 @@ class splashScreen(wx.SplashScreen): # rectangle while the app is loading self.Bind(wx.EVT_CLOSE, self.OnClose) - def DoDestroy(self): - self.Destroy() def OnClose(self, e): if self.callback: # Avoid calling the callback twice - self.callback() + cb = self.callback self.callback = None - wx.CallAfter(self.DoDestroy) + # The callback will destroy us + wx.CallAfter(cb) + e.Skip()