How can I create a GVariant* to feed to g_variant_iter_new?

285 views Asked by At

The following simple code is sufficient to reproduce the error I am having.

#include <gio/gio.h>

int main()
{
    GVariantIter *Iter;
    const gchar* s = "[('appname', uint64 size, uint64 field, false)]";
    GVariant* up = g_variant_new_string(s);
    Iter = g_variant_iter_new(up);
    return 0;
}

It is resulting in:

GLib:ERROR:../../../glib/gvariant-serialiser.c:1367:g_variant_serialised_n_children: code should not be reached Bail out! GLib:ERROR:../../../glib/gvariant-serialiser.c:1367:g_variant_serialised_n_children: code should not be reached Aborted

What am I missing? The documentation is somewhat vague.

g_variant_new_string ()

GVariant * g_variant_new_string (const gchar *string);
Creates a string GVariant with the contents of string.

g_variant_iter_new ()

GVariantIter * g_variant_iter_new (GVariant *value);
Creates a heap-allocated GVariantIter for iterating over the items in value.
0

There are 0 answers