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 536060 - Please register a GType for the 'metadata' signal parameter of entry-parsed
Please register a GType for the 'metadata' signal parameter of entry-parsed
Status: RESOLVED FIXED
Product: totem-pl-parser
Classification: Core
Component: General
2.23.x
Other Linux
: Normal normal
: ---
Assigned To: totem-pl-parser-maint
totem-pl-parser-maint
Depends on:
Blocks: 503343
 
 
Reported: 2008-06-01 14:05 UTC by Gustavo Carneiro
Modified: 2008-08-22 14:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
like this? (1.65 KB, patch)
2008-06-02 06:57 UTC, Christian Persch
committed Details | Review
patch to replace G_TYPE_HASHTABLE (2.57 KB, patch)
2008-06-29 20:25 UTC, Gustavo Carneiro
none Details | Review
patch v2, uses g_once_enter/leave (2.78 KB, patch)
2008-06-29 21:48 UTC, Gustavo Carneiro
none Details | Review

Description Gustavo Carneiro 2008-06-01 14:05:34 UTC
Like the summary says.  G_TYPE_POINTER is too vague and does not allow Python bindings to handle it.
Comment 1 Christian Persch 2008-06-02 06:57:51 UTC
Created attachment 111924 [details] [review]
like this?
Comment 2 Christian Persch 2008-06-02 06:59:01 UTC
Btw, totemplparser-marshal.[ch] are generated files, but also are in svn. Shouldn't they not be in svn?
Comment 3 Bastien Nocera 2008-06-02 09:00:53 UTC
(In reply to comment #2)
> Btw, totemplparser-marshal.[ch] are generated files, but also are in svn.
> Shouldn't they not be in svn?

No idea how they got in there. You can remove them.
Comment 4 Gustavo Carneiro 2008-06-02 09:29:30 UTC
(In reply to comment #1)
> Created an attachment (id=111924) [edit]
> like this?
> 

Sorry, no.  It does not help much to know it is a hash table.  What type are keys and values?  Could be anything, not just char* -> char*...  I can't assume anything.  And pygobject does not allow per-signal-parameter conversion functions, only per-GType conversion functions.

It would be better to register a TOTEM_TYPE_METATADA or TOTEM_TYPE_STR_TO_STR_HASH_TABLE type, which be otherwise identical to G_TYPE_HASH_TABLE.
Comment 5 Bastien Nocera 2008-06-02 09:37:24 UTC
(In reply to comment #4)
> (In reply to comment #1)
> > Created an attachment (id=111924) [edit]
> > like this?
> > 
> 
> Sorry, no.  It does not help much to know it is a hash table.  What type are
> keys and values?  Could be anything, not just char* -> char*...  I can't assume
> anything.  And pygobject does not allow per-signal-parameter conversion
> functions, only per-GType conversion functions.
> 
> It would be better to register a TOTEM_TYPE_METATADA or
> TOTEM_TYPE_STR_TO_STR_HASH_TABLE type, which be otherwise identical to
> G_TYPE_HASH_TABLE.

Currently, all the types available outside the internal API will be strings, but there's no telling that this will stay that way...
Comment 6 Christian Persch 2008-06-02 16:02:06 UTC
(In reply to comment #4)
> (In reply to comment #1)
> > Created an attachment (id=111924) [edit]
> > like this?
> Sorry, no. 
Ok. However I think the patch is correct and should be applied, even if it doesn't fix this particular problem.
Comment 7 Christian Persch 2008-06-10 12:46:35 UTC
	* plparse/totem-pl-parser.c: (totem_pl_parser_class_init),
	(totem_pl_parser_add_url_valist):
	* plparse/totemplparser-marshal.list: Use G_TYPE_HASH_TABLE in the
	signals to transport the hash table, and use g_hash_table_unref
	instead of g_hash_table_destroy so that the signal handler may
	usefully keep a reference to the hash table. Patch from bug #536060.

Comment 8 Gustavo Carneiro 2008-06-29 14:05:48 UTC
(In reply to comment #7)
>         * plparse/totem-pl-parser.c: (totem_pl_parser_class_init),
>         (totem_pl_parser_add_url_valist):
>         * plparse/totemplparser-marshal.list: Use G_TYPE_HASH_TABLE in the
>         signals to transport the hash table, and use g_hash_table_unref
>         instead of g_hash_table_destroy so that the signal handler may
>         usefully keep a reference to the hash table. Patch from bug #536060.
> 

Would you accept a patch from me that registered a boxed type TOTEM_TYPE_PL_PARSER_METADATA, otherwise identical to G_TYPE_HASH_TABLE, and use it for that signal?  That would allow me to close the gnome-python-desktop bug (and this one too).
Comment 9 Bastien Nocera 2008-06-29 14:29:41 UTC
(In reply to comment #8)
<snip>
> Would you accept a patch from me that registered a boxed type
> TOTEM_TYPE_PL_PARSER_METADATA, otherwise identical to G_TYPE_HASH_TABLE, and
> use it for that signal?  That would allow me to close the gnome-python-desktop
> bug (and this one too).

Sure, if you think that's going to fix the problem...
Comment 10 Gustavo Carneiro 2008-06-29 20:25:00 UTC
Created attachment 113642 [details] [review]
patch to replace G_TYPE_HASHTABLE
Comment 11 Christian Persch 2008-06-29 21:14:01 UTC
+  static GType type_id = 0;
+  if (!type_id)

Should use g_once_init_enter/leave here, just like any other G_DEFINE_TYPE does.

Why don't you derive this new type from G_TYPE_HASHTABLE instead of just from G_TYPE_BOXED ?

Is this a totem-pl-parser specific problem, or does this sort of problem occur in other places too? I think there ought to be gobject support for registering the key and value GTypes of a G_TYPE_HASHTABLE derived type...
Comment 12 Christian Persch 2008-06-29 21:26:03 UTC
(In reply to comment #11)
> Why don't you derive this new type from G_TYPE_HASHTABLE instead of just from
> G_TYPE_BOXED ?

Hmm, so apparently it's not possible to further derive a type from a boxed type, at least none that I can see that would also do the extra work that g_boxed_type_register_static does... 
Comment 13 Gustavo Carneiro 2008-06-29 21:48:19 UTC
(In reply to comment #11)
> +  static GType type_id = 0;
> +  if (!type_id)
> 
> Should use g_once_init_enter/leave here, just like any other G_DEFINE_TYPE
> does.

Hm.. well, I copied the type registration code straight from GLib, g_hash_table_get_type, with only some renaming being done.  But I'll do it anyway.

> 
> Why don't you derive this new type from G_TYPE_HASHTABLE instead of just from
> G_TYPE_BOXED ?

Apparently not possible.

> 
> Is this a totem-pl-parser specific problem, or does this sort of problem occur
> in other places too? I think there ought to be gobject support for registering
> the key and value GTypes of a G_TYPE_HASHTABLE derived type...
> 

For Python bindings, it is impossible to do anything with G_TYPE_HASHTABLE, anywhere, because G_TYPE_HASHTABLE does not completely define the type, so it cannot be safely interpreted unless further information is provided to the signal marshaling code.

Well, it's not strictly impossible, but very hard, as it would require pygobject core changes to pass the signal class and signal ID, and would require registration of conversion functions on a (Object GType, Signal ID, Para GType) tuple basis.  But why make things so complicated on language bindings... :P
Comment 14 Gustavo Carneiro 2008-06-29 21:48:59 UTC
Created attachment 113647 [details] [review]
patch v2, uses g_once_enter/leave
Comment 15 Bastien Nocera 2008-08-20 10:39:23 UTC
I'd rather you added casts to the functions in g_boxed_type_register_static() and did away with the one-line function above in your patch.

Looks good to commit after that.
Comment 16 Bastien Nocera 2008-08-22 14:02:57 UTC
Fixed it myself.

2008-06-29  Gustavo J. A. M. Carneiro  <gjc@gnome.org>

	* plparse/totem-pl-parser.c (totem_pl_parser_metadata_get_type),
	* plparse/totem-pl-parser.h: Define a new
	TOTEM_TYPE_PL_PARSER_METADATA, identical to G_TYPE_HASH_TABLE; Use
	it instead of G_TYPE_HASH_TABLE so that Python bindings can safely
	convert metadata signal parameters.  Closes #536060.