[Glade-users] signals



On 2/12/07, Mariano Perez-Sauquillo Perera <mithrandir82 at gmail.com> wrote:
hi, i have tried it, and with a array of chars it works, but with integuers
doesnt work, i have do it like:
 static void callback(GtkWidget *widget, gpointer data)
 {
   int *a;
   a= (int *)data;
   g_print ("%d was passed\n", a[0]);
 }

 ...

 int a[12];
 a[0]=1;
 button = gtk_button_new ();
 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback),
 (gpointer) a);

It won't work because your array (a) is static to the function in
which you calll g_signal_connect(), and so cease to exist once you
exit that function, so in the callback, your 'data' pointer actually
points to some undefined place and any behaviour can then occur if you
try to read it.

Regards,

Vivien




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