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.
This commit is contained in:
Robin Gareus 2019-03-07 17:02:12 +01:00
parent 12a415f077
commit 7b96fa1c5e
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
10 changed files with 34 additions and 12 deletions

View file

@ -24,6 +24,7 @@
#include <gtkmm/menu.h>
#include <gtkmm/menuitem.h>
#include "ardour_ui.h"
#include "time_axis_view.h"
#include "streamview.h"
#include "editor_summary.h"
@ -461,7 +462,7 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
if (ev->button == 3) { // right-click: show the reset menu action
using namespace Gtk::Menu_Helpers;
Gtk::Menu* m = manage (new Gtk::Menu);
Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
MenuList& items = m->items ();
items.push_back(MenuElem(_("Reset Summary to Extents"),
sigc::mem_fun(*this, &EditorSummary::reset_to_extents)));