]> git.saurik.com Git - wxWidgets.git/commitdiff
detect if there was an error in standard GTK+ options processing and exit in such...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Apr 2007 21:19:53 +0000 (21:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Apr 2007 21:19:53 +0000 (21:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/app.cpp

index 31f446d8b69eb367e0d9e8f873b1ed21f5d72eff..ff408b679d5fb23fe15d2972b56d17e590213fd5 100644 (file)
@@ -456,6 +456,38 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     this->argc = argc;
     this->argv = argv;
 
+    if ( m_traits )
+    {
+        // if there are still GTK+ standard options unparsed in the command
+        // line, it means that they were not syntactically correct and GTK+
+        // already printed a warning on the command line and we should now
+        // exit:
+        wxArrayString opt, desc;
+        m_traits->GetStandardCmdLineOptions(opt, desc);
+
+        for ( int i = 0; i < argc; i++ )
+        {
+            // leave just the names of the options with values
+            const wxString str(wxString(argv[i]).BeforeFirst('='));
+
+            for ( size_t j = 0; j < opt.size(); j++ )
+            {
+                // remove the leading spaces from the option string as it does
+                // have them
+                if ( opt[j].Trim(false).BeforeFirst('=') == str )
+                {
+                    // a GTK+ option can be left on the command line only if
+                    // there was an error in (or before, in another standard
+                    // options) it, so abort, just as we do if incorrect
+                    // program option is given
+                    wxLogError(_("Invalid GTK+ command line option, use \"%s --help\""),
+                               argv[0]);
+                    return false;
+                }
+            }
+        }
+    }
+
     if ( !init_result )
     {
         wxLogError(_("Unable to initialize GTK+, is DISPLAY set properly?"));