diff options
author | Tom Hughes <tom@compton.nu> | 2015-03-22 10:55:00 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-03-22 11:16:29 -0400 |
commit | e7eaca95348bbc1aa97b866128402783f21a933a (patch) | |
tree | 203441d3350d787ed2e9105d721a4e0199580b8f /gtk/gtkdnd.c | |
parent | ec32d8dade1e50892e3f96678fe22dae6591ed9f (diff) | |
download | gtk+-e7eaca95348bbc1aa97b866128402783f21a933a.tar.gz |
DND: Clean up weak pointers when they are no longer needed
Failure to do so leads to memory corruption down the road.
This was introduced in commit 650c25e06c17.
https://bugzilla.gnome.org/show_bug.cgi?id=746602
Diffstat (limited to 'gtk/gtkdnd.c')
-rw-r--r-- | gtk/gtkdnd.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 576f67d421..55152090d5 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1637,6 +1637,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, case GDK_DRAG_LEAVE: if (info->widget) { + g_object_remove_weak_pointer (G_OBJECT (info->widget), (gpointer *) &info->widget); gtk_drag_dest_leave (info->widget, context, event->dnd.time); info->widget = NULL; } @@ -1657,6 +1658,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, */ if (info->widget) { + g_object_remove_weak_pointer (G_OBJECT (info->widget), (gpointer *) &info->widget); gtk_drag_dest_leave (info->widget, context, event->dnd.time); info->widget = NULL; } @@ -1689,6 +1691,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, if (info->widget && !found) { + g_object_remove_weak_pointer (G_OBJECT (info->widget), (gpointer *) &info->widget); gtk_drag_dest_leave (info->widget, context, event->dnd.time); info->widget = NULL; } @@ -1918,10 +1921,11 @@ gtk_drag_find_widget (GtkWidget *widget, found = callback (widget, context, x, y, time); /* If so, send a "drag-leave" to the last widget */ - if (found) + if (found && info->widget != widget) { - if (info->widget && info->widget != widget) + if (info->widget) { + g_object_remove_weak_pointer (G_OBJECT (info->widget), (gpointer *) &info->widget); gtk_drag_dest_leave (info->widget, context, time); } @@ -2011,6 +2015,11 @@ gtk_drag_proxy_begin (GtkWidget *widget, static void gtk_drag_dest_info_destroy (gpointer data) { + GtkDragDestInfo *info = (GtkDragDestInfo *)data; + if (info->widget) + { + g_object_remove_weak_pointer (G_OBJECT (info->widget), (gpointer *) &info->widget); + } g_slice_free (GtkDragDestInfo, data); } |