Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: chrome/browser/gtk/browser_toolbar_gtk.cc

Issue 48065: Ensure that MenuGtks are destroyed before their accelerator group. (Closed)
Patch Set: reinterpretcast Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/gtk/menu_gtk.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/browser_toolbar_gtk.cc
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 95fbbbc63827ce221d300bdfec77a9593d065371..f16dd543f07784a91fe5ce08a78871794af58074 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -48,6 +48,12 @@ BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser)
}
BrowserToolbarGtk::~BrowserToolbarGtk() {
+ // When we created our MenuGtk objects, we pass them a pointer to our accel
+ // group. Make sure to tear them down before |accel_group_|.
+ page_menu_.reset();
+ app_menu_.reset();
+ back_forward_menu_.reset();
+ g_object_unref(accel_group_);
}
void BrowserToolbarGtk::Init(Profile* profile,
@@ -63,11 +69,13 @@ void BrowserToolbarGtk::Init(Profile* profile,
// -1 for width means "let GTK do its normal sizing".
gtk_widget_set_size_request(toolbar_, -1, kToolbarHeight);
+ // A GtkAccelGroup is not InitiallyUnowned, meaning we get a real reference
+ // count starting at one. We don't want the lifetime to be managed by the
+ // top level window, since the lifetime should be tied to the C++ object.
+ // When we add the accelerator group, the window will take a reference, but
+ // we still hold on to the original, and thus own a reference to the group.
accel_group_ = gtk_accel_group_new();
gtk_window_add_accel_group(top_level_window, accel_group_);
- // Drop the initial ref on |accel_group_| so that |top_level_window| will own
- // it.
- g_object_unref(accel_group_);
toolbar_tooltips_ = gtk_tooltips_new();
« no previous file with comments | « no previous file | chrome/browser/gtk/menu_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698