diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 22:51:44 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 22:51:44 +0000 |
commit | d1b095c2c98f51386764295e24be3b2343dfe17e (patch) | |
tree | f41373f7d64c0247a7d68bc390453f32eea7e9e8 | |
parent | ff905517f63ea9a3536c9e8a1776a71a6bb9163e (diff) | |
download | chromium_src-d1b095c2c98f51386764295e24be3b2343dfe17e.zip chromium_src-d1b095c2c98f51386764295e24be3b2343dfe17e.tar.gz chromium_src-d1b095c2c98f51386764295e24be3b2343dfe17e.tar.bz2 |
[GTK] clear widget pointer instead of letting it go stale.
BUG=62610
TEST=see bug
Review URL: http://codereview.chromium.org/4820001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65871 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 18 insertions, 18 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 37c6fb5..0580b54 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -153,11 +153,6 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window, } BookmarkBarGtk::~BookmarkBarGtk() { - // A popup menu may be currently showing and holding a pointer back to one - // of our buttons. Be sure it's destroyed first. - current_menu_.reset(); - current_context_menu_.reset(); - RemoveAllBookmarkButtons(); bookmark_toolbar_.Destroy(); event_box_.Destroy(); diff --git a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc index 0fc9101..04a263d 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc @@ -22,12 +22,12 @@ void OnClicked(GtkWidget* widget, bool* clicked_bit) { } // namespace -class BookmarkBarGtkBrowserTest : public InProcessBrowserTest { +class BookmarkBarGtkInteractiveUITest : public InProcessBrowserTest { }; // Makes sure that when you switch back to an NTP with an active findbar, // the findbar is above the floating bookmark bar. -IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) { +IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, FindBarTest) { ASSERT_TRUE(test_server()->Start()); // Create new tab; open findbar. @@ -52,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) { } // Makes sure that you can click on the floating bookmark bar. -IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, ClickOnFloatingTest) { +IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, ClickOnFloatingTest) { ASSERT_TRUE(test_server()->Start()); GtkWidget* other_bookmarks = diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc index 38fc8ef..8924cfb 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc @@ -81,7 +81,7 @@ BookmarkMenuController::BookmarkMenuController(Browser* browser, triggering_widget_(NULL) { menu_ = gtk_menu_new(); BuildMenu(node, start_child_index, menu_); - g_signal_connect(menu_, "hide", + signals_.Connect(menu_, "hide", G_CALLBACK(OnMenuHiddenThunk), this); gtk_widget_show_all(menu_); } @@ -96,6 +96,8 @@ void BookmarkMenuController::Popup(GtkWidget* widget, gint button_type, profile_->GetBookmarkModel()->AddObserver(this); triggering_widget_ = widget; + signals_.Connect(triggering_widget_, "destroy", + G_CALLBACK(gtk_widget_destroyed), &triggering_widget_); gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget), GTK_STATE_ACTIVE); gtk_menu_popup(GTK_MENU(menu_), NULL, NULL, @@ -139,9 +141,9 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, DCHECK(!parent->GetChildCount() || start_child_index < parent->GetChildCount()); - g_signal_connect(menu, "button-press-event", + signals_.Connect(menu, "button-press-event", G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this); - g_signal_connect(menu, "button-release-event", + signals_.Connect(menu, "button-release-event", G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this); for (int i = start_child_index; i < parent->GetChildCount(); ++i) { @@ -158,10 +160,10 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); gtk_util::SetAlwaysShowImage(menu_item); - g_signal_connect(menu_item, "button-release-event", + signals_.Connect(menu_item, "button-release-event", G_CALLBACK(OnButtonReleasedThunk), this); if (node->is_url()) { - g_signal_connect(menu_item, "activate", + signals_.Connect(menu_item, "activate", G_CALLBACK(OnMenuItemActivatedThunk), this); } else if (node->is_folder()) { GtkWidget* submenu = gtk_menu_new(); @@ -177,18 +179,18 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, if (node->is_url()) target_mask |= gtk_dnd_util::TEXT_URI_LIST | gtk_dnd_util::NETSCAPE_URL; gtk_dnd_util::SetSourceTargetListFromCodeMask(menu_item, target_mask); - g_signal_connect(menu_item, "drag-begin", + signals_.Connect(menu_item, "drag-begin", G_CALLBACK(OnMenuItemDragBeginThunk), this); - g_signal_connect(menu_item, "drag-end", + signals_.Connect(menu_item, "drag-end", G_CALLBACK(OnMenuItemDragEndThunk), this); - g_signal_connect(menu_item, "drag-data-get", + signals_.Connect(menu_item, "drag-data-get", G_CALLBACK(OnMenuItemDragGetThunk), this); // It is important to connect to this signal after setting up the drag // source because we only want to stifle the menu's default handler and // not the handler that the drag source uses. if (node->is_folder()) { - g_signal_connect(menu_item, "button-press-event", + signals_.Connect(menu_item, "button-press-event", G_CALLBACK(OnFolderButtonPressedThunk), this); } @@ -267,7 +269,7 @@ gboolean BookmarkMenuController::OnMenuButtonPressedOrReleased( // context menu is hidden, re-assert our grab. GtkWidget* grabbing_menu = gtk_grab_get_current(); g_object_ref(grabbing_menu); - g_signal_connect(context_menu_->widget(), "hide", + signals_.Connect(context_menu_->widget(), "hide", G_CALLBACK(OnContextMenuHide), grabbing_menu); context_menu_->PopupAsContext(event->time); diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.h b/chrome/browser/gtk/bookmark_menu_controller_gtk.h index cf8443c..0060267 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.h +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.h @@ -10,6 +10,7 @@ #include "app/gtk_integers.h" #include "app/gtk_signal.h" +#include "app/gtk_signal_registrar.h" #include "base/scoped_ptr.h" #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" @@ -136,6 +137,8 @@ class BookmarkMenuController : public BaseBookmarkModelObserver, scoped_ptr<BookmarkContextMenuController> context_menu_controller_; scoped_ptr<MenuGtk> context_menu_; + GtkSignalRegistrar signals_; + DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); }; |