From: Youness Alaoui Date: Sun, 28 Dec 2014 01:36:24 +0000 (-0500) Subject: Add a 100ms timeout to the splash screen to allow it to show X-Git-Tag: 14.09-1.18~9 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0dd10e033df7b4db99320b2a83d2f56c55211e08;p=cura.git Add a 100ms timeout to the splash screen to allow it to show Without it, the callback would get called before the splash screen events got processed (such as Paint?) which will cause the splash screen not to appear or to appear as a grey rectangle without the image This could potentially fix issue #14 --- diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py index e2a2613a..27463f5f 100644 --- a/Cura/gui/splashScreen.py +++ b/Cura/gui/splashScreen.py @@ -8,9 +8,18 @@ class splashScreen(wx.SplashScreen): def __init__(self, callback): self.callback = callback bitmap = wx.Bitmap(getPathForImage('splash.png')) - super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN, 0, None) - wx.CallAfter(self.DoCallback) + super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 100, None) + # Add a timeout and call the callback in the close event to avoid having the callback called + # before the splashscreen paint events which could cause it not to appear or to appear as a grey + # rectangle while the app is loading + self.Bind(wx.EVT_CLOSE, self.OnClose) - def DoCallback(self): - self.callback() + def DoDestroy(self): self.Destroy() + + def OnClose(self, e): + if self.callback: + # Avoid calling the callback twice + self.callback() + self.callback = None + wx.CallAfter(self.DoDestroy)