After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 549734 - gtk_selection_data_get_data prototype is wrong
gtk_selection_data_get_data prototype is wrong
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.13.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-08-28 17:21 UTC by Christian Dywan
Modified: 2008-08-29 08:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix prototype (1.73 KB, patch)
2008-08-28 17:21 UTC, Christian Dywan
committed Details | Review

Description Christian Dywan 2008-08-28 17:21:02 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.
Comment 1 Christian Dywan 2008-08-28 17:21:43 UTC
Created attachment 117538 [details] [review]
Fix prototype
Comment 2 Owen Taylor 2008-08-28 17:27:50 UTC
Incompatible change, suggest WONTFIX. The current prototype is perfectly legitimate since negative lengths are impossible.
Comment 3 Christian Dywan 2008-08-28 17:38:30 UTC
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.
Comment 4 Michael Natterer 2008-08-28 17:51:29 UTC
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.
Comment 5 Owen Taylor 2008-08-28 18:37:47 UTC
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.
Comment 6 Matthias Clasen 2008-08-29 04:28:19 UTC
I've added a separate gtk_selection_data_get_length now.
Comment 7 Michael Natterer 2008-08-29 08:15:02 UTC
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.
Comment 8 Michael Natterer 2008-08-29 08:23:38 UTC
Wait, this was nonsense :) length is indeed the length in bytes. Seems
to confuse me each time...