Re: passing #define'd value to callback
- From: Peter Wurmsdobler <peter wurmsdobler ctm-france com>
- To: Darin Adler <darin eazel com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: passing #define'd value to callback
- Date: Fri, 13 Oct 2000 09:59:14 +0200
Darin,
The technique definitely works; I have done it many times and seen it many
places throughout the Gtk code too. It seems you have some other bug if you
got a segmentation fault. The fact that GINT_TO_POINTER(0) is the same as
NULL is irrelevant. Nothing tries to dereference the pointer.
Not really, it's not a bug it's a feature, because I set a variable
in shm to be the data. Seg fault. Now its clear. What really happens:
common.h:
#define ON (1)
#define OFF (0)
xmcm.c:
static int on = ON;
static int off = OFF;
void mm_spin_radiobutton_clicked( GtkButton *button,
gpointer data )
{
if ( GTK_TOGGLE_BUTTON(button)->active )
shm->mm_spin = *((int *)(data));
}
gtk_signal_connect(
GTK_OBJECT( mm_on_radiobutton ), "clicked",
GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ), &on );
gtk_signal_connect(
GTK_OBJECT( mm_off_radiobutton ), "clicked",
GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ), &off );
rt_mcm.c:
if ( shm->mm_state == ON )
pthread_make_periodic_np( rt_mcm_mm_control_thread,
start_time, MM_CONTROL_TS );
This code works but is not too elegant. So I was looking
for something simpler.
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]