diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 19:22:57 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 19:22:57 +0000 |
commit | 697b87dd539e18cf21d5e65a7e55919f615e394c (patch) | |
tree | 523ab4fe14c2d884dd5d492fb0471b3b5c18ee58 /chrome/browser | |
parent | e9923cb7a30065c91964acecf537fe15c2bf768e (diff) | |
download | chromium_src-697b87dd539e18cf21d5e65a7e55919f615e394c.zip chromium_src-697b87dd539e18cf21d5e65a7e55919f615e394c.tar.gz chromium_src-697b87dd539e18cf21d5e65a7e55919f615e394c.tar.bz2 |
Fix accel leak in task manager and bookmark manager by using
the same cleanup code as browser_window_gtk.
Also fix a leak of the gtk widgets when the accelerator was
not used for the task manager. If the user closed by using the
window manager destroy, then we never called gtk_widget_destroy
on the window and leaked the widgets.
Review URL: http://codereview.chromium.org/202035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 13 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.h | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/task_manager_gtk.cc | 17 | ||||
-rw-r--r-- | chrome/browser/gtk/task_manager_gtk.h | 2 |
4 files changed, 21 insertions, 13 deletions
diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index fe5d749..7c89476 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -322,6 +322,10 @@ BookmarkManagerGtk::~BookmarkManagerGtk() { gtk_paned_get_position(GTK_PANED(paned_))); SaveColumnConfiguration(); model_->RemoveObserver(this); + + gtk_accel_group_disconnect_key(accel_group_, GDK_w, GDK_CONTROL_MASK); + gtk_window_remove_accel_group(GTK_WINDOW(window_), accel_group_); + g_object_unref(accel_group_); } void BookmarkManagerGtk::InitWidgets() { @@ -416,13 +420,10 @@ void BookmarkManagerGtk::InitWidgets() { } void BookmarkManagerGtk::ConnectAccelerators() { - GtkAccelGroup* accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); - - // Drop the initial ref on |accel_group| so |window_| will own it. - g_object_unref(accel_group); + accel_group_ = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group_); - gtk_accel_group_connect(accel_group, + gtk_accel_group_connect(accel_group_, GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0), g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); diff --git a/chrome/browser/gtk/bookmark_manager_gtk.h b/chrome/browser/gtk/bookmark_manager_gtk.h index c8df6b3..c86150c 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.h +++ b/chrome/browser/gtk/bookmark_manager_gtk.h @@ -340,6 +340,8 @@ class BookmarkManagerGtk : public BookmarkModelObserver, // This is used to avoid recursively calling our right click handler. It is // only true when a right click is already being handled. bool ignore_rightclicks_; + + GtkAccelGroup* accel_group_; }; #endif // CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc index f7f9906..ebe66a0 100644 --- a/chrome/browser/gtk/task_manager_gtk.cc +++ b/chrome/browser/gtk/task_manager_gtk.cc @@ -249,6 +249,13 @@ TaskManagerGtk* TaskManagerGtk::instance_ = NULL; TaskManagerGtk::~TaskManagerGtk() { task_manager_->OnWindowClosed(); model_->RemoveObserver(this); + + gtk_accel_group_disconnect_key(accel_group_, GDK_w, GDK_CONTROL_MASK); + gtk_window_remove_accel_group(GTK_WINDOW(dialog_), accel_group_); + g_object_unref(accel_group_); + accel_group_ = NULL; + + gtk_widget_destroy(dialog_); } //////////////////////////////////////////////////////////////////////////////// @@ -431,13 +438,10 @@ void TaskManagerGtk::SetInitialDialogSize() { } void TaskManagerGtk::ConnectAccelerators() { - GtkAccelGroup* accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group(GTK_WINDOW(dialog_), accel_group); - - // Drop the initial ref on |accel_group| so |dialog_| will own it. - g_object_unref(accel_group); + accel_group_ = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(dialog_), accel_group_); - gtk_accel_group_connect(accel_group, + gtk_accel_group_connect(accel_group_, GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0), g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); @@ -717,7 +721,6 @@ gboolean TaskManagerGtk::OnGtkAccelerator(GtkAccelGroup* accel_group, // is destroyed. The deleted object will receive gtk signals otherwise. gtk_dialog_response(GTK_DIALOG(task_manager->dialog_), GTK_RESPONSE_DELETE_EVENT); - gtk_widget_destroy(task_manager->dialog_); } return TRUE; diff --git a/chrome/browser/gtk/task_manager_gtk.h b/chrome/browser/gtk/task_manager_gtk.h index ee44ab7e..50f813c 100644 --- a/chrome/browser/gtk/task_manager_gtk.h +++ b/chrome/browser/gtk/task_manager_gtk.h @@ -112,6 +112,8 @@ class TaskManagerGtk : public TaskManagerModelObserver { // The context menu controller. scoped_ptr<ContextMenuController> menu_controller_; + GtkAccelGroup* accel_group_; + // An open task manager window. There can only be one open at a time. This // is reset to NULL when the window is closed. static TaskManagerGtk* instance_; |