radiobutton callback



Hello,

Actually I want to pass different predefined values to
a single callback for two radiobuttons, but the callback
seems to be called twice for a single mouse click, and
in addition the passed data changes. I do:

void spin_radiobutton_clicked( GtkButton *button, gpointer data )
    {
    int *x = data;
    printf("*x = %d\n", *x );
    }

void create(void)
    {
    int spin_right = RIGHT;
    int spin_left  = LEFT;

    spin_group = NULL;
    spin_left_radiobutton = 
        gtk_radio_button_new_with_label( spin_group, 
        LEFT_RADIOBUTTON_TEXT );
    spin_group = gtk_radio_button_group( 
        GTK_RADIO_BUTTON( spin_left_radiobutton) );
    gtk_signal_connect( 
        GTK_OBJECT( spin_left_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( spin_radiobutton_clicked ),
        &spin_left );

    spin_right_radiobutton = 
        gtk_radio_button_new_with_label( spin_group, 
        RIGHT_RADIOBUTTON_TEXT );
    spin_group = gtk_radio_button_group( 
        GTK_RADIO_BUTTON( spin_right_radiobutton) );
    gtk_signal_connect( 
        GTK_OBJECT( spin_right_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( spin_radiobutton_clicked ),
        &spin_right );
    }

Even though I thought of using something like &RIGHT instead
of using an extra int spin_right = RIGHT; anyway, the debug
messages show:

*x = -1073743848
*x = 134836864

*x = 134836864
*x = 0

*x = 0
*x = 134836864

So, sometimes it works, sometimes not, which makes me
think that a pointer is freed sometimes. Any hints?
peterw
-- 
Dr. Peter Wurmsdobler

      CTM - Centre de Transfert des Microtechniques
39, av. de l'Observatoire, BP-1445, 25007 Besancon CEDEX 3
TELEPHONE: +33 3 81 47 70 20  TELECOPIE: +33 3 81 47 70 21
         E-mail: peter wurmsdobler ctm-france com

                  Ceterum censeo MIRCOSOFTem esse delendam.




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