GtkCList data pointers.



Hi. I am working on a small project which uses GTK+ as its GUI.

I have one GtkCList which i am trying to associate data pointers to,
but have discovered something wierd:

In here, for example, number == 0:

int somefunc() {
        
        gchar *filename_to_add;
        gchar *full_path;                

        gtk_clist_insert((GtkCList *)p_list, number, filename_to_add);
        gtk_clist_set_row_data((GtkCList *)p_list, number, full_path);

        g_print("Putting %s into number %d\n", 
                (gchar *)gtk_clist_get_row_data((GtkCList *)p_list,
		number),                          
                number);
}

full_path gets set to "/usr/home/something", and indeed the functions
outputs
"Putting /usr/home/something into number 0".

But - When I try to read the same associated data pointer(same GtkCList)
from another function, I get random
Garbage, which is totally unrelated, like different Window titles from
my application,
Random file names and the likes. Am I doing something wrong in here, or
is this a knwon bug?

Another Example:

(...down along the code)

int some_other_func() {
        i = 0;
        g_print("got %s from number %d\n", 
	(gchar*)gtk_clist_get_row_data((GtkCList *)p_list, 
	i), i);
}

outputs "got Select Dependencies from number 0". ?!
        
The variables are initialized and I am using g_malloc0() before trying
to put anything into them,
so It is not possible that I am doing this somewhere else in the code.

Ive been breaking my teeth over this for the past day, so finally ive
decided this is worth
bothering you guys.


Anyone?:)

thanks, Gilad.



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