Commit e7eaca95 authored by Tom Hughes's avatar Tom Hughes Committed by Matthias Clasen

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 650c25e0.

https://bugzilla.gnome.org/show_bug.cgi?id=746602
parent ec32d8da
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment