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

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

Issue 1783010: GTK: more signal handler foolproofing. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 8 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 | « chrome/browser/gtk/menu_bar_helper.h ('k') | chrome/browser/gtk/options/content_page_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/menu_bar_helper.cc
diff --git a/chrome/browser/gtk/menu_bar_helper.cc b/chrome/browser/gtk/menu_bar_helper.cc
index 54fa555fd8ccc05d07f39e814d9598188f2ec9ca..d5d42aeb68718af5e871c87758d7c235eefee222 100644
--- a/chrome/browser/gtk/menu_bar_helper.cc
+++ b/chrome/browser/gtk/menu_bar_helper.cc
@@ -79,16 +79,19 @@ void MenuBarHelper::MenuStartedShowing(GtkWidget* button, GtkWidget* menu) {
DCHECK(GTK_IS_MENU(menu));
button_showing_menu_ = button;
showing_menu_ = menu;
- g_signal_connect(menu, "motion-notify-event",
- G_CALLBACK(OnMenuMotionNotifyThunk), this);
- g_signal_connect(menu, "hide",
- G_CALLBACK(OnMenuHiddenThunk), this);
- g_signal_connect(menu, "move-current",
- G_CALLBACK(OnMenuMoveCurrentThunk), this);
+
+ signal_handlers_.reset(new GtkSignalRegistrar());
+ signal_handlers_->Connect(menu, "motion-notify-event",
+ G_CALLBACK(OnMenuMotionNotifyThunk), this);
+ signal_handlers_->Connect(menu, "hide",
+ G_CALLBACK(OnMenuHiddenThunk), this);
+ signal_handlers_->Connect(menu, "move-current",
+ G_CALLBACK(OnMenuMoveCurrentThunk), this);
gtk_container_foreach(GTK_CONTAINER(menu), PopulateSubmenus, &submenus_);
+
for (size_t i = 0; i < submenus_.size(); ++i) {
- g_signal_connect(submenus_[i], "motion-notify-event",
- G_CALLBACK(OnMenuMotionNotifyThunk), this);
+ signal_handlers_->Connect(submenus_[i], "motion-notify-event",
+ G_CALLBACK(OnMenuMotionNotifyThunk), this);
}
}
@@ -138,14 +141,8 @@ gboolean MenuBarHelper::OnMenuMotionNotify(GtkWidget* menu,
void MenuBarHelper::OnMenuHidden(GtkWidget* menu) {
DCHECK_EQ(showing_menu_, menu);
- int matched = g_signal_handlers_disconnect_matched(showing_menu_,
- G_SIGNAL_MATCH_DATA, 0, NULL, NULL, NULL, this);
- DCHECK_EQ(3, matched);
- for (size_t i = 0; i < submenus_.size(); ++i) {
- g_signal_handlers_disconnect_by_func(submenus_[i],
- reinterpret_cast<gpointer>(OnMenuMotionNotifyThunk), this);
- }
+ signal_handlers_.reset();
showing_menu_ = NULL;
button_showing_menu_ = NULL;
submenus_.clear();
« no previous file with comments | « chrome/browser/gtk/menu_bar_helper.h ('k') | chrome/browser/gtk/options/content_page_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698