]> git.saurik.com Git - wxWidgets.git/commitdiff
copied from old cocoa code from David, fixes #13732
authorStefan Csomor <csomor@advancedconcepts.ch>
Thu, 8 Dec 2011 17:08:10 +0000 (17:08 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Thu, 8 Dec 2011 17:08:10 +0000 (17:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/app.cpp

index a3ea0229337d9227f0122097dd11aff6ed2328ec..edf1ffac4b4f46c36fc9bbf0eaad968cc5591ed9 100644 (file)
@@ -811,6 +811,36 @@ 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");
+        if( wxStrncmp(argv[i], ARG_NS, wxStrlen(ARG_NS)) == 0 )
+        {
+            // Only eat this option if it has an argument
+            if( (i + 1) < argc )
+            {
+                argc -= 2;
+                memmove(argv + i, argv + i + 2, argc * sizeof(char *));
+                // drop back one position so the next run through the loop
+                // reprocesses the argument at our current index.
+                --i;
+            }
+        }
+    }
+
     if ( !wxAppBase::Initialize(argc, argv) )
         return false;