From c76d1ea417f340c296f49a0d8f87bd737503ba56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 15 Feb 2014 16:59:18 +0000 Subject: [PATCH] OS X: fix startup sequence when restoring session on >=10.7. Make sure that OnInit() is called before MacReopenApp(). This is normally the case, but it is possible for it to be called as the first thing. This can happen when OS X restores running apps when starting a new user session. Apps that were hidden (dock only) when the previous session terminated are only restored in a limited, resources-saving way - the event loop is running, but didn't call anything in the app delegate yet. When the user clicks the icon, applicationShouldHandleReopen: is called, but we didn't call OnInit() yet. In this case, we shouldn't call MacReopenApp(), but should proceed with normal initialization. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/utils.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 664ed5159b..0d42873f1b 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -109,7 +109,16 @@ void wxBell() { wxUnusedVar(flag); wxUnusedVar(sender); - wxTheApp->MacReopenApp() ; + if ( wxTheApp->OSXInitWasCalled() ) + wxTheApp->MacReopenApp(); + // else: It's possible that this function was called as the first thing. + // This can happen when OS X restores running apps when starting a new + // user session. Apps that were hidden (dock only) when the previous + // session terminated are only restored in a limited, resources-saving + // way. When the user clicks the icon, applicationShouldHandleReopen: + // is called, but we didn't call OnInit() yet. In this case, we + // shouldn't call MacReopenApp(), but should proceed with normal + // initialization. return NO; }