Chromium Code Reviews| 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..c0b14acfc7aa11fbf3822b4d9707ccabd08ecb76 100644 |
| --- a/content/browser/web_contents/web_drag_dest_gtk.cc |
| +++ b/content/browser/web_contents/web_drag_dest_gtk.cc |
| @@ -58,25 +58,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 also update the number of handlers in |
| + // ~WebDragDestGtk. |
| + handlers_.reset(new int[5]); |
|
Charlie Reis
2013/03/14 22:08:38
Magic numbers aren't good. Better to declare a kN
mthiesse
2013/03/15 15:26:49
Done.
|
| + 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 < 5; ++i) |
| + g_signal_handler_disconnect(widget_, handlers_.get()[i]); |
| } |
| } |