From 9e9574fe45b176ee74bba8fad7574cf9906145d1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Aug 2013 14:33:22 +0000 Subject: [PATCH] Move code removing "-psn_xxx" command line arguments to common code. We need to do this when using any port under OS X, not just wxOSX, e.g. the -psn_xxx arguments passed by the Finder when launching the application, must also be ignored when using wxGTK. Closes #15432. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/appcmn.cpp | 21 +++++++++++++++++++++ src/osx/carbon/app.cpp | 15 --------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 5321885ed4..821f695bac 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -83,6 +83,27 @@ wxAppBase::wxAppBase() bool wxAppBase::Initialize(int& argcOrig, wxChar **argvOrig) { +#ifdef __WXOSX__ + // Mac OS X passes a process serial number command line argument when + // the application is launched from the Finder. This argument must be + // removed from the command line arguments before being handled by the + // application (otherwise applications would need to handle it) + // + // Notice that this has to be done for all ports that can be used under OS + // X (e.g. wxGTK) and not just wxOSX itself, hence this code is here and + // not in a port-specific file. + if ( argcOrig > 1 ) + { + static const wxChar *ARG_PSN = wxT("-psn_"); + if ( wxStrncmp(argvOrig[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) + { + // remove this argument + --argcOrig; + memmove(argvOrig + 1, argvOrig + 2, argcOrig * sizeof(wxChar*)); + } + } +#endif // __WXOSX__ + if ( !wxAppConsole::Initialize(argcOrig, argvOrig) ) return false; diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index 5285c21bd8..30fb4b076f 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -821,21 +821,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) InstallDebugAssertOutputHandler( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) ); #endif - // Mac OS X passes a process serial number command line argument when - // the application is launched from the Finder. This argument must be - // removed from the command line arguments before being handled by the - // application (otherwise applications would need to handle it) - if ( argc > 1 ) - { - static const wxChar *ARG_PSN = wxT("-psn_"); - if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) - { - // remove this argument - --argc; - memmove(argv + 1, argv + 2, argc * sizeof(wxChar*)); - } - } - /* Cocoa supports -Key value options which set the user defaults key "Key" to the value "value" Some of them are very handy for debugging like -- 2.45.2