problems passing data via g_signal_connect

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

 



Hello:
I am having a problem printing out the data I pass to my callback function.
I am using the g_signal_connect. The callback function is getting called,
 but the data is messed up/empty.

This is what I am doing:

1. The struct holding the data: 
typedef struct my_data { 
char bin[1000]; 
char doc[1000]; 
} MY_DATA;

2. Setup the callback: 

MY_DATA mydata; 

strcpy(mydata.bin,"TESTING"); 
printf("Data is <%s> before callback activated\n",mydata.bin); 
printf("Data is at %p before callback activated\n",mydata); 

g_signal_connect(G_OBJECT (tableCells[r][6]), 
                 "button_press_event", 
                 G_CALLBACK (selectActionBin),  
                 (gpointer) &mydata); 

3. The callback function 
void selectActionBin(MY_DATA *data) 
{ 
printf("In CB, data = <%s>\n",data->bin); 
printf("In CB, data is at %p\n", data); 
printf("In CB, data is at %p\n", &data); 
gtk_widget_show (selectDialog_window); <--- This shows up as expected.

}

4.Result. 
./testIt 
---- The following prints out from #2 above 
Data is <TESTING> before callback activated 
Data is at 0x504f4f50 before callback activated 

---- The following prints out from #3 above 
In CB, data = <> <---- I want to see my data here :{ 
In CB, data is at 0x80b2a30 
In CB, data is at 0xbfffeb40 



Any help would be apprecited. 
O 









Concerned about your privacy? Follow this link to get
FREE encrypted email: https://www.hushmail.com/?l=2

Free, ultra-private instant messaging with Hush Messenger
https://www.hushmail.com/services.php?subloc=messenger&l=434

Promote security and make money with the Hushmail Affiliate Program: 
https://www.hushmail.com/about.php?subloc=affiliate&l=427
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux