summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 23:56:15 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 23:56:15 +0000
commit6debdd4b159057619e9b53b975b335796aa163a5 (patch)
treea32451f4024b6ccd889ae2668ddfc04ec15b347f /chrome/browser/gtk
parentba28602ec8163bce988c0738b1b594652a81a298 (diff)
downloadchromium_src-6debdd4b159057619e9b53b975b335796aa163a5.zip
chromium_src-6debdd4b159057619e9b53b975b335796aa163a5.tar.gz
chromium_src-6debdd4b159057619e9b53b975b335796aa163a5.tar.bz2
GTK: Fix memory leak from r27666.
Make MenuGtk take ownership of submenus. BUG=none TEST=valgrind doesn't complain Review URL: http://codereview.chromium.org/251053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc2
-rw-r--r--chrome/browser/gtk/menu_gtk.h4
-rw-r--r--chrome/browser/gtk/standard_menus.cc1
-rw-r--r--chrome/browser/gtk/standard_menus.h4
4 files changed, 8 insertions, 3 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index f63f23b..e166030 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -41,6 +41,7 @@ MenuGtk::MenuGtk(MenuGtk::Delegate* delegate, bool load)
MenuGtk::~MenuGtk() {
menu_.Destroy();
+ STLDeleteContainerPointers(submenus_we_own_.begin(), submenus_we_own_.end());
if (dummy_accel_group_)
g_object_unref(dummy_accel_group_);
}
@@ -173,6 +174,7 @@ void MenuGtk::BuildMenuIn(GtkWidget* menu,
} else if (menu_data->custom_submenu) {
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
menu_data->custom_submenu->menu_.get());
+ submenus_we_own_.push_back(menu_data->custom_submenu);
}
if ((menu_data->only_show || accel_group) && menu_data->accel_key) {
diff --git a/chrome/browser/gtk/menu_gtk.h b/chrome/browser/gtk/menu_gtk.h
index f0dc661..8baf3002 100644
--- a/chrome/browser/gtk/menu_gtk.h
+++ b/chrome/browser/gtk/menu_gtk.h
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
#include <string>
+#include <vector>
#include "base/task.h"
#include "chrome/common/owned_widget_gtk.h"
@@ -150,6 +151,9 @@ class MenuGtk {
// menu.
static bool block_activation_;
+ // We must free these at shutdown.
+ std::vector<MenuGtk*> submenus_we_own_;
+
ScopedRunnableMethodFactory<MenuGtk> factory_;
};
diff --git a/chrome/browser/gtk/standard_menus.cc b/chrome/browser/gtk/standard_menus.cc
index c798fbbb..261375e 100644
--- a/chrome/browser/gtk/standard_menus.cc
+++ b/chrome/browser/gtk/standard_menus.cc
@@ -107,7 +107,6 @@ struct MenuCreateMaterial standard_app_menu_materials[] = {
} // namespace
-
const MenuCreateMaterial* GetStandardPageMenu(Profile* profile,
MenuGtk::Delegate* delegate) {
EncodingMenuController controller;
diff --git a/chrome/browser/gtk/standard_menus.h b/chrome/browser/gtk/standard_menus.h
index 15c3734..3a8d806 100644
--- a/chrome/browser/gtk/standard_menus.h
+++ b/chrome/browser/gtk/standard_menus.h
@@ -49,8 +49,8 @@ struct MenuCreateMaterial {
// toolbar_view.cc::GetAcceleratorInfo().
bool only_show;
- // If non-NULL, specifies a custom submenu to be used.
- // The menu lifetime must at least match this menu's lifetime.
+ // If non-NULL, specifies a custom submenu to be used. MenuGtk will take
+ // ownership of this submenu.
MenuGtk* custom_submenu;
};