GNOME Bugzilla – Bug 132716
OptionMenu::set_history() invalidates MenuList::Item::get_child() with NULL pointer
Last modified: 2004-12-22 21:47:04 UTC
set_history() on an option menu with ImageMenuElems causes the label pointer to be set to NULL colorClassMenu = manage(new Gtk::OptionMenu()) baseMenu = manage(new Gtk::Menu()); ......snip....... Gtk::Label *classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[0].get_child()); cout << "MENU CLASS 0 before " << classLabel << endl; classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[1].get_child()); cout << "MENU CLASS 1 before " << classLabel << endl; colorClassMenu->set_history(0); cout << "HIST" << colorClassMenu->get_history() << endl; classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[0].get_child()); cout << "MENU CLASS 0 after set 0 " << classLabel << endl; classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[1].get_child()); cout << "MENU CLASS 1 after set 0 " << classLabel << endl; colorClassMenu->set_history(1); cout << "HIST" << colorClassMenu->get_history() << endl; classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[0].get_child()); cout << "MENU CLASS 0 after set 1 " << classLabel << endl; classLabel = dynamic_cast<Gtk::Label*>(baseMenu->items()[1].get_child()); cout << "MENU CLASS 1 after set 1 " << classLabel << endl; ----------------------------------------- MENU CLASS 0 before 0x8144a78 MENU CLASS 1 before 0x8145338 HIST0 MENU CLASS 0 after set 0 0 MENU CLASS 1 after set 0 0x8145338 HIST0 MENU CLASS 0 after set 1 0x8144a78 MENU CLASS 1 after set 1 0 configuration data: [voldemort]~/WORK/zing: rpm -qa | grep gtk gtkglarea-1.2.2-16 gtkhtml2-devel-2.2.0-6 gtkmm2-devel-2.2.3-fr1 gtkmm2-2.2.3-fr1 gtk-engines-0.12-2.0 authconfig-gtk-4.3.7-1 gtk+-1.2.10-27.1 gnome-python2-gtkhtml2-1.99.14-5 gtkam-0.1.7-6 gtk2-devel-2.2.4-4.0 gtk2-engines-2.2.0-2 gtkam-gimp-0.1.7-6 usermode-gtk-1.68-5 gtkhtml2-2.2.0-6 gtkhtml3-3.0.9-4 gtk2-2.2.4-4.0 pygtk-0.6.9-7.ximian.2 pygtk2-devel-1.99.16-8 gtk+-devel-1.2.10-27.1 gtk-doc-1.1-3.0 pygtk2-1.99.16-8 pygtk2-libglade-1.99.16-8
Can we have a simple-as-possible, compilable, test case please?
Created attachment 30911 [details] Test case Test case
On further inspection, this is because of a bug in the Gtk C API.
In fact, close this bug, it is how Gtk is supposed to work -- the menuitem's child seems to 'disappear' because it is just reparented to the optionmenu when it is the actively displayed item.
OK. Thanks.