Patch #2882 2009-12-27 21:07

techy

Call SetDesc() of the command-line parser only once(debug10)
Download
2882-Call_SetDesc_o.patch (1.0 KB)
Category
Application::Bugfix
Status
Accepted
Close date
2010-02-03 17:44
Assigned to
mortenmacfly
Index: src/src/app.cpp
===================================================================
--- src/src/app.cpp    (revision 5986)
+++ src/src/app.cpp    (working copy)
@@ -489,6 +489,9 @@
 
     wxTheClipboard->Flush();
 
+    wxCmdLineParser& parser = *Manager::GetCmdLineParser();
+    parser.SetDesc(cmdLineDesc);
+
     // NOTE: crash handler explicitly disabled because it causes problems
     //       with plugins loading/unloading...
     //
@@ -533,8 +536,6 @@
             if(connection)
             {
                 wxArrayString strFilesInCommandLine;
-                wxCmdLineParser& parser = *Manager::GetCmdLineParser();
-                parser.SetDesc(cmdLineDesc);
                 parser.SetCmdLine(argc, argv);
 
                 // search for valid filenames passed as argument on commandline
@@ -1036,7 +1037,6 @@
 
 #if wxUSE_CMDLINE_PARSER
     wxCmdLineParser& parser = *Manager::GetCmdLineParser();
-    parser.SetDesc(cmdLineDesc);
     parser.SetCmdLine(argc, argv);
     // wxApp::argc is a wxChar**
 
techy 2009-12-27 21:11

Now, SetDesc() of the command-line parser can be called multiple times, which is not correct because next time it's called it tries to add the same command-line parameters again, which fails because they are already present. This patch does it once in OnInit().

mortenmacfly 2009-12-28 19:47

This didn't compile in the first place as parser appeared twice in the same method. Be careful! (Hopefully you are testing the patches, don't you?! ;-))

techy 2009-12-28 22:28

Huh, interesting - it compiles just fine with gcc 4.4.1 and I don't get any warnings even with -Wall (but I'm pretty sure that gcc 3.3.3 I use at work wouldn't like that). See the revised patch - it should fix it.