Re: [sigc] =?iso-8859-1?q?is_it_possible_to_disconnect_without_storin?= =?iso-8859-1?q?g=09=60sigc=3A=3Aconnection=27=3F?=



klaus triendl wrote:
> Paul Pogonyshev wrote:
>  > Hi,
>  >
>  > In C-level GTK+ there is a function named  g_signal_handlers_disconnect_matched().
>  > It can be used to disconnect, for instance, particular handlers (i.e.  with
>  > matching function) of an object.  Is something similar possible with libsigc++
>  > or do I have to store `sigc::connection' objects around?
> 
> Hi Paul,
> 
> When you connect to a signal you get an iterator back from 
> signal::connect().
> You could use this iterator or copy the slot the iterator points to and 
> then call it->disconnect() or slotcopy.disconnect();
> 
> Note however that the iterator is only valid as long as the signal's 
> slot list is valid.
> Connections have a trackable mechanism and are therefore safer.

Right, I know this.  I wondered if I could not store connection objects,
as I know what handlers _this_ object has connected to a signal.  I wished
to remove them just by (object + function) pair.

Here is situation I have.   Object A has a pointer to some model, B.  It
connects to some signals in B to listen for some events.  Now, if the
model changes to C, A has to disconnect its handlers from B and connect
them to C instead.  I wondered if I could do that without storing
connections, as that seems excessive.

Paul



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