Re: [gtk-list] Re: Apprarently simple signal/event question
- From: Havoc Pennington <hp redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Apprarently simple signal/event question
- Date: 12 Dec 1999 22:14:45 -0500
"Peter Wright" <firstname.lastname@example.org> writes:
> So, if I have this right, using
> gint signalblahblah( GtkWidget *, gpointer )
> to handle the delete_event event works, as in compiles and runs, but it's
> completely unwise to presume that the same would always be the case. What I
Any function signature will compile and run, because GTK_SIGNAL_FUNC()
casts it to the expected type (otherwise you'd need a different
gtk_signal_connect() for each type). Basically, think of GtkSignalFunc
as a void pointer for functions.
However, no matter what function you connect to delete_event, GTK will
pass it three arguments (object, event, gpointer) and it will try to
use the value the function returns - if you pass in a function with no
return value, GTK will get random memory junk instead of a sensible
> mean is that there is a chance with other events that using this type of
> event handler would cause a problem in terms of memory corruption, a crash
> etc etc ?
You should always use the proper callback function type for the signal
you're connecting to, or problems are quite likely. They don't always
happen for various reasons (some random, some guaranteed by C) but
they will happen.
> Also, what about what Peter Garner said - does GTK_SIGNAL_FUNC( ), really
> cast both the signal type callback and the event type callback to the same
> thing ?
GTK_SIGNAL_FUNC() is nothing but (GtkSignalFunc) i.e. a cast to avoid
] [Thread Prev