Re: [gtk-list] GtkCList data pointers.



On Wed, 30 Sep 1998, Gilad Rom wrote:

> 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);

where do you get filename_to_add from? if you e.g. retrive the current value
from an GtkEntry which will not duplicate the string contents for you, you
need to copy the string so it doesn't get messed up by other things working
on your data. i.e. try:
gtk_clist_set_row_data_full ((GtkCList*) p_list,
                             number,
                             g_strdup (filename_to_add),
                             g_free);


>         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?

[...]

> 
> thanks, Gilad.
> 

---
ciaoTJ



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