Re: [gtk-list] BIG BUG in gtk+!



>  Whenever a pointer is sent as an argument to a signal hander
>  function for "delete_event", the pointer is messed up.  This
>  happened in three programs (two of which aren't mine) that I've
>  checked.  This causes the program to crash if you utilize one of
>  the members...

These programs are buggy, not Gtk+.  This has got to be the number 1
FAQ about Gtk+ signals.

Now.  Repeat after me.

NOT ALL SIGNAL HANDLERS HAVE THE SAME SIGNATURES.

Again, in a different form.

HANDLERS FOR DIFFERENT SIGNALS NEED DIFFERENT PROTOTYPES.

If you look at gtkwidget.h, you'll see the required prototype for
delete_event.  In gtkwidget.h, around line 301:

  gint (* delete_event)		   (GtkWidget	       *widget,
				    GdkEventAny	       *event);

Handlers for the delete_event signal must return a gint, and they take
*three* arguments:  the widget argument, the event argument, and then
the user data:

  gint my_delete_event_handler (GtkWidget *widget, GdkEventAny *event, gpointer data);

Any other prototype handler is wrong.

  Federico



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