Tree Iter?

Hi, i am working on a program en i have a problem:

I have a GtkTree wich contains a few rows with names of forums,
topics of these forums should be added to the tree as childs of the
forum. So when I have a forum called "Cars Online "(CO), with a topic
named "Why is my car broken?", 

  Why is my car broken?

Should appear in the Tree (with the topic as a child of the forum).
When adding a topic it should be added to the correct Forum, so i put
all forums in a GList with Iters to them to be able to create a new
child of that Forum, But i got the following error:

(test:1544): Gtk-CRITICAL **: file gtktreestore.c: line 1381
(gtk_tree_store_append): assertion `VALID_ITER (parent, tree_store)'

Somehow the Iter isnt valid after being stored in a GList.

how can i solve this?


GList *frms, *tpx;         /* the glists to contain the structs, 
                              they are set to NULL in a init function */

typedef struct _forum {
        gchar *title;
        GtkTreeIter iter;    /* the structs contain a lot more info but 
                                that doesnt matter for this problem */
} forum;

typedef struct _topic {
        gchar *title;
        gchar *num_replies;
        GtkTreeIter iter;
} topic;

/* This function works well, the forum is added to the Tree
 * Just like it should, so far no problems */

add_forum_to_tree(gchar *frmname)  {

forum *temp = g_new(forum,1);             /* create a new forum struct*/
temp->title = g_strdup(frmname);

gtk_tree_store_append(store, &(temp->iter), NULL);      /*append iter */
gtk_tree_store_set(store, &(temp->iter), NAME_COLLUMN, temp->title, -1);

frms = g_list_add(frms,temp);  /* add the forum to the GList */

add_topic_to_tree(gchar *frmname, gchar *title, gchar *replies) {

GList *browse = NULL;
forum *frm_temp;
topic *temp = g_new (topic, 1);
temp->title = g_strdup(title);
temp->replies = g_strdup(replies);

for(browse=frms; browse; browse=frms->next) { /* browse frms GList*/

frm_temp = (forum *)browse->data;

if(!strcmp(frm_temp->title,frmname)) {

/* it works so far, when i add prinf("%s\n",frm_temp->title);
 * it displays the title, but from here it goes wrong */

gtk_tree_store_append(store, &(frm_temp->iter), &(temp->iter));
gtk_tree_store_set(store, &(temp->iter), NAME_COLLUMN, temp->title,-1);

/* this didnt work, somehow frm_temp->iter isnt useable after it has
been in the GList. */

tpx = g_list_append(tpx,temp);


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