The code computing the position of the popup menu used to compare the
given string to each MenuItem::get_label() result, but that method
actually replaces the content (child) of the MenuItem if that child is
not already a Gtk::Label. In particular, this breaks menu separators.
Avoid the issue by checking by hand if the only child of the MenuItem is
a Label, and directly compare the label text.
MenuList::const_iterator i = items.begin();
for ( ; i != items.end(); ++i) {
- if (selected == ((std::string) i->get_label())) {
+ const Label* label_widget = dynamic_cast<const Label*>(i->get_child());
+ if (label_widget && selected == ((std::string) label_widget->get_label())) {
break;
}
offset += i->size_request().height;