Boost logo

Boost Users :

From: Alejandro Martínez (elpeque2_at_[hidden])
Date: 2008-05-13 09:30:39


I have this problem.

Im using boost::bind for programming the call-back mechanism for a gui
system and to pass messages (possibly, delayed messages).

My problem is, that when i bind member functions, if i specify the
instance of the class as a shared_ptr, then i get memory leaks because
the binding's shared_ptr to the instance keeps it alive, and it potentially
produces cyclic references that in the current model, would be complicated
to break.

And of course, if i use raw pointers to the binding instances, then i'll
get a crash if the instance has been destroyed and i try to execute the
binding function.

So what i would need, is to use bind with weak pointers, and just do
nothing if locking it fails.

I'm not sure how to do that, or how to assemble a good walkaround. I'd
like it to be as automatic as possible.

Thanks for your time, i appreciate any help :)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net