GNOME Bugzilla – Bug 613269
g_type_get_qdata() doesn't work as I expected on subtypes
Last modified: 2011-02-21 16:23:16 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.
Created attachment 156504 [details] [review] Document that g_type_get_qdata() doesn't handle subtypes
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?
Sigh. “attributed” should read “unattributed”.
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.
(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 …) :)