GNOME Bugzilla – Bug 534685
Bin::add_label passes wrong parameters to Label constructor
Last modified: 2008-06-03 18:25:34 UTC
Please describe the problem: The order of arguments is inconsistent between Bin::add_label and Label::Label. The former passes Label* label = manage(new Label(str, mnemonic, x_align, y_align)); The latter expects mnemonic to be the last argument: Label::Label(const Glib::ustring& label, float xalign, float yalign, bool mnemonic) Unfortunately float and bool are convertible, so the compiler does not pick up the error, but it manifests at run-time with wrong alignments and (most notably) underscores being used to specify mnemonics when you did not intend it. Steps to reproduce: 1. Create a menu 2. Use remove, and add_label to change the label on a menu item. Use a string containing '_'. 3. Pop up the menu. Actual results: You will see that the '_' has been used to underline the following character as a mnemonic, although you did not intend this (the default value of "mnemonic" should be false). Expected results: Underscores should not be treated as mnemonics. Does this happen every time? Yes Other information:
Would you like to make a patch for this against svn?
Created attachment 111948 [details] [review] Patch against svn head OK, here's a patch
Thanks. Committed to svn trunk. Please patch the ChangeLog in future. Hopefully you can work around this before it appears in a tarball. I didn't even know that this method existed. I don't see what these Bin::add_*() methods are good for.
Thanks. I don't consider myself a developer on this project, so I didn't think to patch the ChangeLog, sorry. There is a lot of stuff in the GTK interface that is not obviously useful, but if you use it heavily you'll almost certainly come across a case where it is the only way to accomplish what you need to do. I'm working on a GTK interface to the DDD debugger - I use these routines to change the labels on the popup menu which appears when you right-click on a function or variable name in the source window: so you get "Break at ...", "Print ...", "Display ...", and so on. It saves having to tear down and rebuild the entire menu.
I'm sure you'll be interested in the nemiver debugger project. It uses gtkmm.