GNOME Bugzilla – Bug 692844
Incorrect (out) annotation on gtk_tree_drag_source_drag_data_get
Last modified: 2013-03-15 16:12:06 UTC
As of 2fb1c064020c5db189285b1d5e8b8dcea8e9d09b, gtk_tree_drag_source_drag_data_get's GtkSelectionData argument is marked as (out). I don't think that's correct, for two reasons: a) GtkSelectionData is semi-private (it's declared in gtkselectionprivate.h), and thus gobject-introspection has no knowledge of its fields or its size. There is thus no way for language bindings to allocate GtkSelectionData. b) Even if it was possible for language bindings to allocate GtkSelectionData, a zeroed-out instance thus created would not be usable with gtk_tree_drag_source_drag_data_get. As far as I can tell, you need to initialize its "target" member to the GdkAtom of "GTK_TREE_MODEL_ROW". Language bindings have no way of knowing this, of course.
Created attachment 234782 [details] [review] treednd: Remove (out) annotation from GtkSelectionData arg
This seems right as it really is an (in) argument which you can call methods on to modify? I don't know the internals but when I briefly looked at bug 690678 I actually suggested the argument needs to be marked as "inout" :) Based on your comment and trying to create a SelectionData from Python, we just get a MemoryError exception. As long as Python is wrapping the incoming object as shared memory and not copying it, it seems like the attached patch will also fix bug 690678 and make it compatible with the pygtk bindings.
I certainly agree with the patch, the only problem is that I cannot find commit 2fb1c064020c5db189285b1d5e8b8dcea8e9d09b in my freshly synced git repo, and even http://git.gnome.org/browse/gtk+/tree/gtk/gtktreednd.c#n133 shows that there is currently no (out) annotation present. Although it is still early morning and I'm probably doing something stupid :-)
Umm, yes, I did something stupid. Of course, that commit does exist and is mine, and the patch is also correct. I'm waking up slowly :-) As for suggested (inout) annotation, I don't think that it would be correct here. AFAIK (inout) would be appropriate only if argument signature would be 'GtkSelectionData **selection_data' and function would have to look at the contents of *selection_data and upon return sets (allocates) new value to *selection_data
Review of attachment 234782 [details] [review]: Looks fine to me, thanks!
*** Bug 690678 has been marked as a duplicate of this bug. ***
Thanks for the reviews. Committed.
Can this fix go onto the gtk+ 3.6 branch as well? It is another missing piece for the Sugar drag and drop functionality and the OLPC images are currently based on 3.6 for another while.