From f0f8b239ef6cb53fa415d0d012ff4920634dd6df Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 1 Oct 2014 15:35:01 -0400 Subject: [PATCH] fix WavesDropdown when used with radio menu items ::clear_items() would render the RadioMenuItem::group() invalid, thus causing crashes if the dropdown is populated, cleared and repopulated. So redesign things to avoid a member group. --- gtk2_ardour/waves_dropdown.cc | 9 ++++++++- gtk2_ardour/waves_dropdown.h | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/waves_dropdown.cc b/gtk2_ardour/waves_dropdown.cc index 2f56a714da..f4bbccdd0c 100644 --- a/gtk2_ardour/waves_dropdown.cc +++ b/gtk2_ardour/waves_dropdown.cc @@ -84,7 +84,14 @@ WavesDropdown::add_radio_menu_item (const std::string& item, void* cookie) { Gtk::Menu_Helpers::MenuList& items = _menu.items (); - items.push_back (Gtk::Menu_Helpers::RadioMenuElem (_radio_menu_items_group, item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), items.size (), cookie))); + if (items.empty()) { + Gtk::RadioMenuItem::Group group; + items.push_back (Gtk::Menu_Helpers::RadioMenuElem (group, item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), items.size (), cookie))); + } else { + Gtk::RadioMenuItem* first = dynamic_cast (&_menu.items ().front ()); + Gtk::RadioMenuItem::Group group = first->get_group(); + items.push_back (Gtk::Menu_Helpers::RadioMenuElem (group, item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), items.size (), cookie))); + } Gtk::RadioMenuItem& menuitem = *dynamic_cast (&_menu.items ().back ()); ensure_style(); diff --git a/gtk2_ardour/waves_dropdown.h b/gtk2_ardour/waves_dropdown.h index 756990167e..e810c87f68 100644 --- a/gtk2_ardour/waves_dropdown.h +++ b/gtk2_ardour/waves_dropdown.h @@ -46,7 +46,6 @@ class WavesDropdown : public WavesIconButton private: Gtk::Menu _menu; int _selected_item_number; - Gtk::RadioMenuItem::Group _radio_menu_items_group; void _on_menu_item (int item_number, void* cookie); void _on_popup_menu_position (int& x, int& y, bool& push_in); bool _on_mouse_pressed (GdkEventButton*);