gtkdnd.c race condition?



I've just implemented drag and drop on linux-fb, and I have a problem with
the generic gtkdnd code. Specifically this code in gtk_drag_update:

  if (gdk_drag_motion (info->context, dest_window, protocol,
		       x_root, y_root, action,
		       possible_actions,
		       time))
    {
      if (info->last_event)
	gdk_event_free ((GdkEvent *)info->last_event);

      info->last_event = gdk_event_copy ((GdkEvent *)event);
    }

I get an assert in gdk_event_copy due to the fact that info->last_event ==
event.

Here is what i think happens:
1) User moves mouse, leading to a call to gtk_drag_update().
2) gdk_drag_motion() sets src_context->drag_state to
   GDK_DRAG_STATUS_MOTION_WAIT and sends a GDK_DRAG_MOTION event.
Before the destination gets to run gdk_drag_status() to set drag_status
back to GDK_DRAG_STATUS_DRAG the user moves the mouse again.
3) gdk_drag_motion() is called again, but returns TRUE because it will not
send anything until it gets gdk_drag_status(). Since it returns true, the
event will be stored in info->last_event.
4) now we get the GDK_DRAG_STATUS event, which leads
gtk_drag_source_handle_event() calls gtk_drag_update() with the
info->last_event as parameter.

Can i check in this patch?

/ Alex

Index: gtkdnd.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkdnd.c,v
retrieving revision 1.56
diff -u -p -r1.56 gtkdnd.c
--- gtkdnd.c	2000/12/04 16:11:51	1.56
+++ gtkdnd.c	2001/01/16 12:15:42
@@ -2658,10 +2658,13 @@ gtk_drag_update (GtkDragSourceInfo *info
 		       possible_actions,
 		       time))
     {
+      GdkEvent *event_copy;
+      event_copy = gdk_event_copy ((GdkEvent *)event);
+
       if (info->last_event)
 	gdk_event_free ((GdkEvent *)info->last_event);

-      info->last_event = gdk_event_copy ((GdkEvent *)event);
+      info->last_event = event_copy;
     }

   if (dest_window)








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]