Blame cura-lulzbot-wizard.patch

2a78819
From 08c5f2133c9dbc8b986bc727c0b9768d9e45ccfd Mon Sep 17 00:00:00 2001
2a78819
From: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
2a78819
Date: Tue, 7 Jul 2015 15:48:07 -0400
2a78819
Subject: [PATCH] Prevent multiple calls to afterSplashCallback
2a78819
2a78819
This fixes issue #133. Problem was that if splash.OnClose was called
2a78819
before the afterSplashCallback was done (such as, if it's blocking
2a78819
on a configWizard), then the callback would be called again.
2a78819
This also fixes a segmentation fault if you cancel the initial config wizard
2a78819
by making sure the callback is done outside the event thread and splash
2a78819
destruction is done at the proper time and from the proper thread.
2a78819
---
2a78819
 Cura/gui/app.py          | 18 +++++++++---------
2a78819
 Cura/gui/splashScreen.py |  8 ++++----
2a78819
 2 files changed, 13 insertions(+), 13 deletions(-)
2a78819
2a78819
diff --git a/Cura/gui/app.py b/Cura/gui/app.py
2a78819
index 8f4fb00..3caf494 100644
2a78819
--- a/Cura/gui/app.py
2a78819
+++ b/Cura/gui/app.py
2a78819
@@ -99,6 +99,12 @@ def Win32SocketListener(self, port):
2a78819
 		except:
2a78819
 			pass
2a78819
 
2a78819
+	def destroySplashScreen(self):
2a78819
+		if self.splash is not None:
2a78819
+			self.splash.Show(False)
2a78819
+			self.splash.Destroy()
2a78819
+			self.splash = None
2a78819
+
2a78819
 	def afterSplashCallback(self):
2a78819
 		#These imports take most of the time and thus should be done after showing the splashscreen
2a78819
 		import webbrowser
2a78819
@@ -134,26 +140,20 @@ def afterSplashCallback(self):
2a78819
 			exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'Rocktopus.stl'))
2a78819
 
2a78819
 			self.loadFiles = [exampleFile]
2a78819
-			if self.splash is not None:
2a78819
-				self.splash.Show(False)
2a78819
-				self.splash = None
2a78819
+			self.destroySplashScreen()
2a78819
 			configWizard.ConfigWizard()
2a78819
 
2a78819
 		if profile.getPreference('check_for_updates') == 'True':
2a78819
 			newVersion = version.checkForNewerVersion()
2a78819
 			if newVersion is not None:
2a78819
-				if self.splash is not None:
2a78819
-					self.splash.Show(False)
2a78819
-					self.splash = None
2a78819
+				self.destroySplashScreen()
2a78819
 				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:
2a78819
 					webbrowser.open(newVersion)
2a78819
 					return
2a78819
 		if profile.getMachineSetting('machine_name') == '':
2a78819
 			return
2a78819
 		self.mainWindow = mainWindow.mainWindow()
2a78819
-		if self.splash is not None:
2a78819
-			self.splash.Show(False)
2a78819
-			self.splash = None
2a78819
+		self.destroySplashScreen()
2a78819
 		self.SetTopWindow(self.mainWindow)
2a78819
 		self.mainWindow.Show()
2a78819
 		self.mainWindow.OnDropFiles(self.loadFiles)
2a78819
diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py
2a78819
index 44bad77..a3568a0 100644
2a78819
--- a/Cura/gui/splashScreen.py
2a78819
+++ b/Cura/gui/splashScreen.py
2a78819
@@ -14,13 +14,13 @@ def __init__(self, callback):
2a78819
 		# rectangle while the app is loading
2a78819
 		self.Bind(wx.EVT_CLOSE, self.OnClose)
2a78819
 
2a78819
-	def DoDestroy(self):
2a78819
-		self.Destroy()
2a78819
 
2a78819
 	def OnClose(self, e):
2a78819
 		if self.callback:
2a78819
 			# Avoid calling the callback twice
2a78819
-			self.callback()
2a78819
+			cb = self.callback
2a78819
 			self.callback = None
2a78819
-		wx.CallAfter(self.DoDestroy)
2a78819
+			# The callback will destroy us
2a78819
+			wx.CallAfter(cb)
2a78819
+
2a78819
 		e.Skip()