Re: [gtk-list] Unexplained Gtk Warning




Matthew <matthew@mattshouse.com> writes:

> I'm using the gtk_signal_handlers_destroy() function to remove a signal from
> a toggle button.  However, when I remove the signal I get the following warning:
> Gtk-WARNING **: gtk_signal_disconnect_by_data(): could not find handler containing data (0x8159E00)
> 
> Could someone tell me how to avoid the warning?  Here is some example code:
> 
>     /* First, I need to get rid of the toggle signal */
>     gtk_signal_handlers_destroy(GTK_OBJECT (tbut));
> 
>     /* Now I want to toggle the button without the callback executing */
>     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(tbut), TRUE);  
> 
>     /* Now let's turn the signal back on */
>     gtk_signal_connect (GTK_OBJECT (tbut), "clicked",
> 			GTK_SIGNAL_FUNC (obj_on_cache_clicked),
> 			NULL);

Don't call gtk_signal_handlers_destroy() - to quote the header file:

/* Non-public methods */
void   gtk_signal_handlers_destroy	  (GtkObject	       *object);
[..]

Basically that function removes all the handlers, including 
other handlers not installed by you. What you probably want
to use here is:

void   gtk_signal_handler_block_by_func	  (GtkObject	       *object,
					   GtkSignalFunc	func,
					   gpointer		data);
void   gtk_signal_handler_unblock_by_func (GtkObject	       *object,
					   GtkSignalFunc	func,
					   gpointer		data);
So you can do: 

  gtk_signal_handler_block_by_func (GTK_OBJECT (tbut), 
 			            GTK_SIGNAL_FUNC (obj_on_cache_clicked),
 			            NULL);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(tbut), TRUE);  
  gtk_signal_handler_unblock_by_func (GTK_OBJECT (tbut), 
 			            GTK_SIGNAL_FUNC (obj_on_cache_clicked),
 			            NULL);

Regards,
                                        Owen



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