[gtk+] DND: Clean up weak pointers when they are no longer needed
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] DND: Clean up weak pointers when they are no longer needed
- Date: Sun, 22 Mar 2015 15:17:03 +0000 (UTC)
commit e7eaca95348bbc1aa97b866128402783f21a933a
Author: Tom Hughes <tom compton nu>
Date: Sun Mar 22 10:55:00 2015 +0000
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
gtk/gtkdnd.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 576f67d..5515209 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]