summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_controller.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-03-07 17:02:12 +0100
committerRobin Gareus <robin@gareus.org>2019-03-07 23:50:50 +0100
commit7b96fa1c5e99e054f43ca3272d21ae955bfa3443 (patch)
tree67f2e5efd9ce1890ad3a6444cb114341576d26d3 /gtk2_ardour/automation_controller.cc
parent12a415f0772048f8a38a66a037b024223bc7bbc0 (diff)
Fix some Gtk::Menu memory leaks
A Gtk::manage()d widget will be deleted when its parent container is destroyed. Top-level context menus are not inside a container and hence need to be manually deallocated. The solution here is to use a shared Gtk::Menu pointer that is centrally de/re-allocated. This works because the GUI is single-threaded and at most one context menu is visible at a time.
Diffstat (limited to 'gtk2_ardour/automation_controller.cc')
-rw-r--r--gtk2_ardour/automation_controller.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc
index c7860c53cb..aa37feabb3 100644
--- a/gtk2_ardour/automation_controller.cc
+++ b/gtk2_ardour/automation_controller.cc
@@ -31,6 +31,8 @@
#include "widgets/ardour_button.h"
#include "widgets/ardour_knob.h"
+
+#include "ardour_ui.h"
#include "automation_controller.h"
#include "gui_thread.h"
#include "note_select_dialog.h"
@@ -301,14 +303,14 @@ AutomationController::on_button_release(GdkEventButton* ev)
const ARDOUR::ParameterDescriptor& desc = _controllable->desc();
if (desc.unit == ARDOUR::ParameterDescriptor::MIDI_NOTE) {
- Gtk::Menu* menu = manage(new Menu());
+ Gtk::Menu* menu = ARDOUR_UI::instance()->shared_popup_menu ();
MenuList& items = menu->items();
items.push_back(MenuElem(_("Select Note..."),
sigc::mem_fun(*this, &AutomationController::run_note_select_dialog)));
menu->popup(1, ev->time);
return true;
} else if (desc.unit == ARDOUR::ParameterDescriptor::HZ) {
- Gtk::Menu* menu = manage(new Menu());
+ Gtk::Menu* menu = ARDOUR_UI::instance()->shared_popup_menu ();
MenuList& items = menu->items();
items.push_back(MenuElem(_("Halve"),
sigc::bind(sigc::mem_fun(*this, &AutomationController::set_ratio),