Gtkliststore, invalid string type

Asked

Viewed 28 times

1

The code is giving invalid format string error when passing the Gtkcomboboxtext for a Gtkliststore.

Error: (System:18726): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

struct _list_prod{
    GtkListStore *store;
    GtkWidget *product;
    GtkWidget *quantity;
};

void data_add_main_serv(GtkWidget *widget, gpointer gptr){
        struct _list_prod *lp = (struct _list_prod*) gptr;
        GtkTreeIter iter;

        const char *prod = gtk_combo_box_text_get_active_text(lp->product);

        gtk_list_store_append(lp->store, &iter);
        gtk_list_store_set(lp->store, &iter, 0, prod, 1, gtk_entry_get_text(lp->quantity), NULL);
}

How can I fix this problem?

1 answer

1


Fixed the problem, the method gtk_list_store_set was trying to store an empty string in field 0 of the list.

gtk_list_store_set(lp->store,
        &iter, 0, prod, 1,
        gtk_entry_get_text(lp->quantity),
        NULL);

was just changing the NULL for -1 which is the value q indicates the end of the inserts.

gtk_list_store_set(lp->store,
        &iter, 0, prod, 1,
        gtk_entry_get_text(lp->quantity),
        -1);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.