Re: ?gtk_notebook_remove_page alter other data in structures?



Axel wrote:

I am not sure if it s a bug or a programming error.
Here is the context
I implement a double-linked list, and each element of this list is a structure.
typedef struct tab{
        GtkNotebook *note;
        struct tab* next;
        struct tab* previous;
        int index;
        /* misc data */
        } tab;
typedef tab* list;
typedef list* plist;

The first element : previous = NULL and for the last : next=NULL
all the "note" data of the elements point to the same shared GtkNotebook.

it seems that removing a page of GtkNotebook causes "next" to be modified.

so, imagine I want to close the first tab, here is what I do


plist file,temp;

if ((*file)->prev==NULL)
            {
        /* We are on the first */
            g_print("DELETE THE FIRST\n");
            (*file)=(*file)->next;
            free((*file)->prev);
            (*file)->prev=NULL;
            *temp=*file;
            while (*temp!=NULL)
            {
g_print("BEFORE %d AFTER d\n",(*temp)->index,(*temp)->index-1);
            (*temp)->index=(*temp)->index-1;
            (*temp)=(*temp)->next;
            }
}



so at the end of this "while" loop, the new current "file" pointed value as the good index: 0, since it is the first.

now, i call :

g_print("Current position in file %d\n",(*file)->index);  // result : 0
gtk_notebook_remove_page((*file)->onglets,current_tab);
g_print("Current position in file %d\n",(*file)->index); // result : 1


so, I think there is something strange.
previous was equal to NULL, and next equal to 1
I have checked, it seems that (*file) has been deplaced to his next value : (*file)->next, the index has not been change, it is the adress in *file which has been changed by (*file)->next. (I say that because I can switch to another tabn and then to the first, and I get the right index)


Is it normal ?Or an error in my code ?or a bug?


Axel

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Don' t take attention to this post, I ve made a mistake I just discover
Sorry for noise








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