Re: [gtk-list] Inconsistency(gtk_object_set_data)?
- From: Karl Nelson <kenelson ece ucdavis edu>
- To: gtk-list redhat com
- cc: kenelson sequoia ece ucdavis edu
- Subject: Re: [gtk-list] Inconsistency(gtk_object_set_data)?
- Date: Fri, 03 Mar 2000 20:51:00 -0800
> Hello all,
>
> Below I have two gtk_object_set_datas.
> I can't figure out why the first works and not the second.
>
> void
> on_PE_NewProtocol_button_clicked (GtkButton *button,
> gpointer user_data)
> {
> GtkWidget* Canvas;
> gint State_Count = 0;
> gfloat Zoom = 1.0;
>
> Canvas = lookup_widget ( GTK_WIDGET ( button ) , "PE_PView_canvas" );
>
> gtk_object_set_data ( GTK_OBJECT ( Canvas ) , "state_count" , ( gint*
> ) ( gint ) State_Count );
> gtk_object_set_data ( GTK_OBJECT ( Canvas ) , "zoom" , ( gfloat*
> )(gfloat) Zoom );
> . . .
> }
You have pointed the data to local variables. At the end of the scope
those variable will be gone. True setting data to dynamic memory or
global variables and it will work much better.
If you allocate memory use set_data_full so that you can free the memory
with the object.
--Karl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]