GtkListStore, invalid string type

1

The code is giving an invalid string format error when passing from GtkComboBoxText to a GtkListStore .

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?

    
asked by anonymous 20.09.2016 / 22:00

1 answer

1

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

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

Just change the NULL by -1 which is the value q indicates the end of the insertions.

gtk_list_store_set(lp->store,
        &iter, 0, prod, 1,
        gtk_entry_get_text(lp->quantity),
        -1);
    
20.09.2016 / 22:24