Re: Using iterators like GHashTableIter



On 12/13/2011 01:21 PM, Alberto Mardegan wrote:
>   I'm trying to use libaccounts-glib [0] from python.So far all is good,
> except iterating account settings. In C code, this would work in the
> same way that GHashTable works:
> 
> =============
>     AgAccountSettingIter iter;
>     const gchar *key;
>     const GValue *value;
> 
>     ag_account_settings_iter_init (account, &iter, NULL);
>     while (ag_account_settings_iter_next (&iter, &key, &value))
>     {
>         ...do something with key and value...
>     }
> =============

I could finally get it to work, with a couple of changes which I'm
reporting here for posterity :-)

One problem was that the introspection information for
ag_account_settings_iter_next() was missing the "out" marker on the key
and value parameters. This is how the documentation should be:

=========
 * @key: (out callee-allocates) (transfer none): a pointer to a string
 * receiving the key name.
 * @value: (out callee-allocates) (transfer none): a pointer to a
pointer to a
 * #GValue, to receive the key value.
=========

But this alone didn't fix the crash. The crash was fixed when I
registered AgAccountSettingIter as a boxed type. However, I still don't
understand why I had to do so, and suspect that there's a bug in how
PyGObject currently handles plain structures.

Ciao,
  Alberto


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]