GNOME Bugzilla – Bug 549734
gtk_selection_data_get_data prototype is wrong
Last modified: 2008-08-29 08:23:38 UTC
The function gtk_selection_data_get_data takes a GtkSelectionData * and a guint *, but that's wrong. The 'length' is stored as a gint and should be a gint consequently in the argument type.
Created attachment 117538 [details] [review] Fix prototype
Incompatible change, suggest WONTFIX. The current prototype is perfectly legitimate since negative lengths are impossible.
That function was added within Gtk 2.13 actually, so it's not (yet) incompatible. And gtk_selection_data_set does accept a negative length, so it makes sense to be able to retrieve it back, doesn't it? Arguably this behaviour is slightly peculiar but I'm not sure if it's good to change that in this way now.
This is just a buggy sealing and should be fixed. Did so in SVN: 2008-08-28 Christian Dywan <christian@imendio.com> Bug 549734 – gtk_selection_data_get_data prototype is wrong * gtk/gtkselection.[ch] (gtk_selection_data_get_data): make the 'length' argument of gtk_selection_data_get_data a 'gint', that's what it should be.
Oh, this is GSEAL accessor stuff that was added. If it's new, then please do the right thing and split it into two functions, get_data() and get_length(). If you do that it's fine if you make get_length() return int and -1 for an unset GtkSelectionData. Regarding data_set(), I don't know why I supported passing the combination NULL and a negative number in in revision 1367. I suspect it was defensive. I think was a combination of: - Being defensive - The though that you might want to return the GtkSelectionData object to the original state of data == NULL, length == -1 I doubt anybody has ever used that capability. It would make sense to at least g_return_if_fail() if data != NULL and length is negative, since someone might expect it to do the strlen() thing we do elsewhere. Don't add the strlen() thing however, since data is not a string and may contain embedded nulls.
I've added a separate gtk_selection_data_get_length now.
I agree it's better this way because data's length is *not* "length", it's length * (format / 8), so returning both in the same getter is very confusing.
Wait, this was nonsense :) length is indeed the length in bytes. Seems to confuse me each time...