problem with gtk_signal_connect_object
- From: Stefan Wille <wille netlife de>
- To: gtk-list redhat com
- Subject: problem with gtk_signal_connect_object
- Date: Tue, 19 May 1998 21:40:20 +0200
Hello,
I have a problem with gtk_signal_connect_object which might be bug:
>From what I understand, the function gtk_signal_connect_object connects
a signal of one object to a method of another. If the second objects
gets destroyed, its method shouldn't be called anymore, since a method
should never be invoked on a destroyed object.
But this happens in my program, causing seg faults. It seems like
gtk doesn't disconnect connections to an object that gets destroyed.
I have made a test program:
#include <gtk/gtk.h>
gint some_method (GtkWidget *receiver,
GtkWidget *sender,
GdkEvent *event)
{
printf ("** method on object %p should never be called, since it is
allready destroyed **\n", receiver);
return TRUE;
}
int main (int argc, char **argv)
{
GtkWidget *sender, *receiver;
gtk_init (&argc, &argv);
sender = gtk_window_new (GTK_TOPLEVEL);
gtk_widget_set_events (sender,
gtk_widget_get_events (sender) |
GDK_BUTTON_PRESS_MASK);
receiver = gtk_button_new ();
gtk_signal_connect_object (GTK_OBJECT(sender), "button_press_event",
GTK_SIGNAL_FUNC(some_method),
GTK_OBJECT(receiver));
gtk_widget_destroy (receiver);
printf ("destroyed object %p\n", receiver);
gtk_signal_emit_by_name (GTK_OBJECT(sender), "button_press_event",
NULL);
gtk_exit (0);
return 0;
}
It would be nice if you could help me with this.
Stefan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]