Index: content/browser/web_contents/web_drag_dest_gtk.cc |
diff --git a/content/browser/web_contents/web_drag_dest_gtk.cc b/content/browser/web_contents/web_drag_dest_gtk.cc |
index dcd89b0d8378c7873350e227d53be452c8fb3650..fd2763f05b3b4ca10ef6947f8993553651e4bfb3 100644 |
--- a/content/browser/web_contents/web_drag_dest_gtk.cc |
+++ b/content/browser/web_contents/web_drag_dest_gtk.cc |
@@ -27,6 +27,7 @@ using WebKit::WebDragOperationNone; |
namespace content { |
namespace { |
+const int kNumGtkHandlers = 5; |
int GetModifierFlags(GtkWidget* widget) { |
int modifier_state = 0; |
@@ -58,25 +59,30 @@ WebDragDestGtk::WebDragDestGtk(WebContents* web_contents, GtkWidget* widget) |
static_cast<GdkDragAction>(GDK_ACTION_COPY | |
GDK_ACTION_LINK | |
GDK_ACTION_MOVE)); |
- g_signal_connect(widget, "drag-motion", |
- G_CALLBACK(OnDragMotionThunk), this); |
- g_signal_connect(widget, "drag-leave", |
- G_CALLBACK(OnDragLeaveThunk), this); |
- g_signal_connect(widget, "drag-drop", |
- G_CALLBACK(OnDragDropThunk), this); |
- g_signal_connect(widget, "drag-data-received", |
- G_CALLBACK(OnDragDataReceivedThunk), this); |
+ |
+ // If adding a handler, make sure to update kNumGtkHandlers and add it to the |
+ // |handlers_| array so that it can be disconnected later on. |
+ handlers_.reset(new int[kNumGtkHandlers]); |
+ handlers_.get()[0] = g_signal_connect( |
+ widget, "drag-motion", G_CALLBACK(OnDragMotionThunk), this); |
+ handlers_.get()[1] = g_signal_connect( |
+ widget, "drag-leave", G_CALLBACK(OnDragLeaveThunk), this); |
+ handlers_.get()[2] = g_signal_connect( |
+ widget, "drag-drop", G_CALLBACK(OnDragDropThunk), this); |
+ handlers_.get()[3] = g_signal_connect( |
+ widget, "drag-data-received", G_CALLBACK(OnDragDataReceivedThunk), this); |
// TODO(tony): Need a drag-data-delete handler for moving content out of |
// the WebContents. http://crbug.com/38989 |
- destroy_handler_ = g_signal_connect( |
+ handlers_.get()[4] = g_signal_connect( |
widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget_); |
} |
WebDragDestGtk::~WebDragDestGtk() { |
if (widget_) { |
gtk_drag_dest_unset(widget_); |
- g_signal_handler_disconnect(widget_, destroy_handler_); |
+ for (int i = 0; i < kNumGtkHandlers; ++i) |
+ g_signal_handler_disconnect(widget_, handlers_.get()[i]); |
} |
} |