Re: The recommended way to destroy a Gtk::Dialog on response?



On 6/6/07, Paul Davis <paul linuxaudiosystems com> wrote:
On Wed, 2007-06-06 at 12:40 -0500, Paul Davis wrote:
> You can also put the object into a smart pointer. I'd recommend
> boost's shared_ptr.

just be very carefeul with shared_ptr and sigc slots. if you ever do
this:

        bind (mem_fun (someObject, &SomeObject::method), aSharedPtrToFoo);

then the created slot holds a reference to Foo that may be hard to get
rid of. if you program sets up objects and only destroys them at
shutdown, if at all, this is not an issue. but if you need careful
management over object lifetimes, this can be a very nasty combination
of two very nice programming idioms.

--p



Definitely. I think somewhere in the archives there's a very in depth
discussion about this. I think it generally came to the point of "Only
bind boost::weak_ptr's, never shared_ptr's"

But definitely, that is one nasty gotchya.

Paul



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