chiark / gitweb /
Add a 100ms timeout to the splash screen to allow it to show
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Sun, 28 Dec 2014 01:36:24 +0000 (20:36 -0500)
committerSteven Abadie <steven@alephobjects.com>
Tue, 30 Dec 2014 22:34:11 +0000 (15:34 -0700)
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

Cura/gui/splashScreen.py

index e2a2613af871dce5394fe788991f8138ac33eae7..27463f5fe2e5f26f868552b4199f2a8f0886e31b 100644 (file)
@@ -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)