Re: slot from a reference pointer



Paul Davis wrote:
> On Wed, 2006-10-11 at 23:23 +0300, Paul Pogonyshev wrote:
> > Paul Davis wrote:
> > > On Wed, 2006-10-11 at 21:15 +0300, Paul Pogonyshev wrote:
> > > > Hi,
> > > > 
> > > > Is there a standard way of getting a sigc++ slot from Glib::RefPtr to
> > > > an object?  I know that I can `steal' the object using operator->(),
> > > > but is there a standard way?
> > > 
> > > its a bad idea anyway. i wrote last month about the perils of using
> > > boost::shared_ptr<T> in slots. it makes life quite complicated.
> > 
> > All Gtkmm objects inherit sigc::trackable (AFAIK), so it makes little
> > sense to add a reference if you create a slot for an object.  If you
> > _really_ want to make slot keeping object alive, you could add a
> > reference by hands. 
> 
> but thats exactly what you would be doing. the slot would have a RefPtr
> stored within it that kept the refcnt up and thus the object alive.
> 
> in boost, you can use weak_ptr<T> to get around this, but RefPtr (AFAIK)
> has no equivalent in part because its not intended to be a general
> purpose shared pointer implementation.

No.  I will use plain sigc::mem_fun getting plain pointer with
operator->().  You cannot (it seems) create a slot using standard
sigc++ functions directly from reference pointer, you need to get
plain pointer first.

Paul



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