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 613269 - g_type_get_qdata() doesn't work as I expected on subtypes
g_type_get_qdata() doesn't work as I expected on subtypes
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-03-18 19:24 UTC by Will Thompson
Modified: 2011-02-21 16:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Document that g_type_get_qdata() doesn't handle subtypes (1.37 KB, patch)
2010-03-18 19:25 UTC, Will Thompson
none Details | Review

Description Will Thompson 2010-03-18 19:24:55 UTC
I spent a while tearing my hair out the other day over a bug which turned out to be because g_type_get_qdata(s, q); doesn't look at supertypes of s, so returns NULL even if you've performed g_type_set_qdata(t, q); where s <: t. The code in question was in an class's constructor, using G_OBJECT_TYPE() to get the GType.

This was not what I expected at all. In this case, we dealt by moving the relevant code to _init(), where G_OBJECT_TYPE() returns the type whose _init() is currently running rather than the type the object will ultimately have. The code in question is a bit suspect, I readily admit, but it'd be nice to at least document that g_type_get_qdata() works like this. Patch to follow.
Comment 1 Will Thompson 2010-03-18 19:25:48 UTC
Created attachment 156504 [details] [review]
Document that g_type_get_qdata() doesn't handle subtypes
Comment 2 Will Thompson 2011-02-21 10:32:16 UTC
Matthias: I discovered by reading the Git history that this is marked fixed because of <http://git.gnome.org/browse/glib/commit/?id=2a1eed2>. I see that you have used my wording, but discarded my example, and committed it under your name with no credit to me.

Obviously this is a trivial example, but this is not the first time that I have submitted fixes that have been committed attributed. This kind of thing really puts me off contributing. Should I in future not seek review for my fixes and just push them directly to master, to avoid losing credit for my work?
Comment 3 Will Thompson 2011-02-21 10:32:56 UTC
Sigh. “attributed” should read “unattributed”.
Comment 4 Matthias Clasen 2011-02-21 16:14:27 UTC
Will, I usually try to mention the original authors of patches that I commit after tweaking. Sorry that I forgot in this case. 

But I will take the freedom to tweak contributions before committing them; if you don't like that maybe writing glib patches is not for you, which would be a shame.

In this case, I didn't feel that a fringe api like type qdata deserved an example.
Comment 5 Will Thompson 2011-02-21 16:23:16 UTC
(In reply to comment #4)
> But I will take the freedom to tweak contributions before committing them; if
> you don't like that maybe writing glib patches is not for you, which would be a
> shame.
> 
> In this case, I didn't feel that a fringe api like type qdata deserved an
> example.

Of course; that's your prerogative, and you're probably right that it's overkill. I notice that I used the word ‘example’ to mean two different things. Sorry for the lack of clarity, and for being overly grumpy about something trivial. (Monday mornings …) :)