Re: [gtk-list] problem with gtk_signal_connect_object



On Tue, 19 May 1998, Stefan Wille wrote:

> 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.
> 

that is intentionall since the slot_object pointer used in the
gtk_signal_connect_object call is guarranteed to be handled by the signaling
system as an opaque pointer, i.e. it might be NULL or the adress of a string
or what else. this is so that you can do

gtk_signal_connect_object (GTK_OBEJCT (button),
			   "clicked",
			   GTK_SIGNAL_FUNC (printf),
			   "The GtkButton::clicked signal has been emitted\n");

for your purpose, that is destroying an existing connection once either of
the two objects get destroyed, the _while_alive connections are in place:

gtk_signal_connect_object_while_alive (GTK_OBJECT (button),
                                       "clicked",
                                       GTK_SIGNAL_FUNC (gtk_widget_destroy),
                                       GTK_OBJECT (my_dialog_window));

this connection will automaticlly be invalidated if either the button or
the my_dialog_window get destroyed.

> 
> Stefan
> 

---
ciaoTJ



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