I have a following issue with GtkTreeView
.
The problem occurs when I'm trying to append the list. Here is my function which creates is:
static GtkWidget *setup_list_archive(GtkWidget **widget)
{
GtkWidget *sc_win;
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
sc_win = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_usize(sc_win, 250, 150);
store = gtk_list_store_new(COL, G_TYPE_STRING, G_TYPE_STRING);
*widget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Klucz", cell, "text", ID, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(*widget), column);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Data", cell, "text", DATA, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(*widget), column);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Godzina", cell, "text", CZAS, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(*widget), column);
// scrolls behavior
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(sc_win), *widget);
// free the objects
g_object_unref(G_OBJECT(store));
return sc_win;
}
And here is my function which appends the list.
static void list_add_archive(GtkWidget* widget, gpointer data)
{
arch *rekord = (arch*) data;
printf("key: %s; pas: %s; dat: %s;\n", rekord->id, rekord->czas, rekord->data);
GtkListStore *store;
GtkTreeIter iter;
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, ID, rekord->id, DATA, rekord->czas, CZAS, rekord->data, -1);
}
The problem occurs only
with multicolumn kind of list. If I create list with one single collumn it works fine.
Here is my backtrace.
key: 1; pas: 14; dat: 2013-06-22 12:24:58;
Breakpoint 1, list_add_archive (widget=0x80e0c40, data=0xbfffe704)
at admin.c:512
512 gtk_list_store_append(store, &iter);
(gdb) step
513 gtk_list_store_set(store, &iter, ID, "a", DATA, "b", CZAS, "c", -1);
(gdb) step
Program received signal SIGSEGV, Segmentation fault.
0xb76b8ff5 in g_type_value_table_peek ()
from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
(gdb) step
Single stepping until exit from function g_type_value_table_peek,
which has no line number information.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) step
The program is not being run.
The line g_type_value_table_peek, which has no line number information
made me think that maybe the enum which defines column numbers isn't correct, I've tryed to write just the integers instead of enum values. It didn't helped.
As you can see on the begging of my debbuger result, there's what printf prints on the screen and so the values in datastructure record
exist and are correct. Anyway I tryed to put const chars in parameters and it changed nothing.
If I pass null
as the parameter of the list it shows only a warning, like invalid cast
et cetera, of course it doesn't work neither :) it's just strange there are no critical errors like segmentation fault.