X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/30cfcda5b541557c598726d272724e2ab1cee45a..ae46a7fd15bff134460b9af46af896136b018fad:/src/cocoa/app.mm diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index c5e4f3dc32..444cccfb89 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -15,7 +15,6 @@ #include "wx/app.h" #ifndef WX_PRECOMP - #include "wx/dc.h" #include "wx/intl.h" #include "wx/log.h" #include "wx/module.h" @@ -26,6 +25,8 @@ #include "wx/cocoa/mbarman.h" #include "wx/cocoa/NSApplication.h" +#include "wx/cocoa/dc.h" + #import #import #import @@ -124,6 +125,37 @@ bool wxApp::Initialize(int& argc, wxChar **argv) } } + /* + 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 + -NSShowAllViews YES. Cocoa picks these up from the real argv so + our removal of them from the wx copy of it does not affect Cocoa's + ability to see them. + + We basically just assume that any "-NS" option and its following + argument needs to be removed from argv. We hope that user code does + not expect to see -NS options and indeed it's probably a safe bet + since most user code accepting options is probably using the + double-dash GNU-style syntax. + */ + for(int i=1; i < argc; ++i) + { + static const wxChar *ARG_NS = wxT("-NS"); + static const int ARG_NS_LEN = wxStrlen(ARG_NS); + if( wxStrncmp(argv[i], ARG_NS, ARG_NS_LEN) == 0 ) + { + // Only eat this option if it has an argument + if( (i + 1) < argc ) + { + argc -= 2; + memmove(argv + i, argv + i + 2, argc * sizeof(wxChar*)); + // drop back one position so the next run through the loop + // reprocesses the argument at our current index. + --i; + } + } + } + return wxAppBase::Initialize(argc, argv); } @@ -131,7 +163,7 @@ void wxApp::CleanUp() { wxAutoNSAutoreleasePool pool; - wxDC::CocoaShutdownTextSystem(); + wxCocoaDCImpl::CocoaShutdownTextSystem(); wxMenuBarManager::DestroyInstance(); [[NSNotificationCenter defaultCenter] removeObserver:sg_cocoaAppObserver]; @@ -157,7 +189,9 @@ wxApp::wxApp() #endif // __WXDEBUG__ argc = 0; +#if !wxUSE_UNICODE argv = NULL; +#endif m_cocoaApp = NULL; m_cocoaAppDelegate = NULL; } @@ -224,7 +258,7 @@ bool wxApp::OnInitGui() if(!sm_isEmbedded) wxMenuBarManager::CreateInstance(); - wxDC::CocoaInitializeTextSystem(); + wxCocoaDCImpl::CocoaInitializeTextSystem(); return true; }