After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 336598 - Glib option parser: Default arguments are overwritten
Glib option parser: Default arguments are overwritten
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
2.8.x
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
: 393571 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-03-30 10:30 UTC by Armin Burgmeier
Modified: 2007-02-10 19:26 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
C version with working default arguments (768 bytes, text/plain)
2006-03-30 10:31 UTC, Armin Burgmeier
  Details
C++ version overriding default arguments (852 bytes, text/plain)
2006-03-30 10:32 UTC, Armin Burgmeier
  Details
Proposed patch (4.10 KB, patch)
2006-03-30 10:32 UTC, Armin Burgmeier
none Details | Review

Description Armin Burgmeier 2006-03-30 10:30:19 UTC
Please describe the problem:
When giving an argument to Glib::OptionGroup::add_entry, glibmm resets it to
zero in Glib::OptionContext::parse if the argument was not given on the command
line. This makes it unpossible to have non-zero default arguments. The problem
does not occur using the plain C API of GOption.

Steps to reproduce:
1. Compile the attached gopt.c.
2. Compile the attached goptmm.cc.
3. Run both without any command line arguments.
4. Compare the results.


Actual results:
The C++ overrides the default arguments, the C version does not.

Expected results:
Both versions produce the same result.

Does this happen every time?
Yes.

Other information:
Comment 1 Armin Burgmeier 2006-03-30 10:31:28 UTC
Created attachment 62373 [details]
C version with working default arguments
Comment 2 Armin Burgmeier 2006-03-30 10:32:09 UTC
Created attachment 62374 [details]
C++ version overriding default arguments
Comment 3 Armin Burgmeier 2006-03-30 10:32:47 UTC
Created attachment 62376 [details] [review]
Proposed patch
Comment 4 Murray Cumming 2006-03-30 12:21:36 UTC
Excellent. I have committed that, with some small changes:
- Some temporary variables to that the code is a little bit more explicit, just to suite my taste.
- Swapped the string/filename parts because filenames should be std::string.
- Used a default value in examples/options/

I also took the hint and used static_cast<> for the other casts in this file.

Well done and thanks.
Comment 5 Murray Cumming 2007-02-10 18:34:25 UTC
Reopened because this doesn't actually seem to have been applied.
Comment 6 Daniel Elstner 2007-02-10 19:15:42 UTC
*** Bug 393571 has been marked as a duplicate of this bug. ***
Comment 7 Murray Cumming 2007-02-10 19:26:29 UTC
I have restored the changes to the glibmm-2-8, glibmm-2-10 and glibmm-2-12 branches. They had survived in trunk (future glibmm 2.13/2.14). It was my fault.