g_list problem



Hi all!

I have a piece of code which looks like this:

    GList *children = g_list_alloc();
    GtkWidget *w = gtk_entry_new();
    gtk_widget_set_name(w, name);
    children = g_list_append(children, (gpointer) w);
    .... // and so on with some other entry widgets using always the 'w'
variable to create and add the children

Then, in a callback function, I do the following

    GList *node = g_list_first(children);        // the children from above
    while (node != NULL)
      {
        if (node->data != NULL && GTK_IS_WIDGET(node->data))
        {
            char *name = gtk_widget_get_name(GTK_WIDGET(node->data));
            .....
        }
        node = g_list_next(node);
      }

The program receives a SIGSEGV in the GTK_IS_WIDGET line and (before, when
this line just was if (node->data != NULL)) in the gtk_widget_get_name()
line.

I ahven't found any documentation on using lists, so I am working from what
I've guessed looking at header files. So, what am I doing wrong?

Thanks very much in advance



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