From 7c7cfb16d391e5f898071259c53a4ecc9879b3e0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 6 Oct 2013 21:12:45 +0000 Subject: [PATCH] get OnInit with complete functionality without loosing sequence for MacOpenFile being called after OnInit git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/app.h | 5 ++++- src/osx/carbon/app.cpp | 1 - src/osx/cocoa/utils.mm | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/wx/osx/app.h b/include/wx/osx/app.h index 723841913c..d841b4127a 100644 --- a/include/wx/osx/app.h +++ b/include/wx/osx/app.h @@ -153,9 +153,12 @@ public: private: bool m_onInitResult; + bool m_inited; + wxArrayString m_openFiles; public: - + bool OSXInitWasCalled() { return m_inited; } + void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; } #endif // Hide the application windows the same as the system hide command would do it. diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index 30e3ba48be..de88ebd8e0 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -403,7 +403,6 @@ void wxApp::MacReopenApp() #if wxOSX_USE_COCOA_OR_IPHONE void wxApp::OSXOnWillFinishLaunching() { - m_onInitResult = OnInit(); } void wxApp::OSXOnDidFinishLaunching() diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 3e07d7dc2c..94215bfb08 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -80,7 +80,10 @@ void wxBell() fileList.Add( wxCFStringRef::AsStringWithNormalizationFormC([fileNames objectAtIndex:i]) ); } - wxTheApp->MacOpenFiles(fileList); + if ( wxTheApp->OSXInitWasCalled() ) + wxTheApp->MacOpenFiles(fileList); + else + wxTheApp->OSXStoreOpenFiles(fileList); } - (BOOL)application:(NSApplication *)sender printFile:(NSString *)filename @@ -112,7 +115,6 @@ void wxBell() withReplyEvent:(NSAppleEventDescriptor *)replyEvent { wxUnusedVar(replyEvent); - wxTheApp->MacNewFile() ; } /* @@ -315,8 +317,18 @@ bool wxApp::CallOnInit() { wxMacAutoreleasePool autoreleasepool; m_onInitResult = false; + m_inited = false; [NSApp run]; - return m_onInitResult; + m_onInitResult = OnInit(); + m_inited = true; + if ( m_onInitResult ) + { + if ( m_openFiles.GetCount() > 0 ) + MacOpenFiles(m_openFiles); + else + MacNewFile(); + } + return m_onInitResult; } void wxApp::DoCleanUp()