Re: [Re: [[gtkmm] technical question: GTKMM_LIFECYCLE]]



MHL Schulze t-online de (Martin Schulze) wrote:
> Am 27.09.2002 20:10 schrieb(en) Murray Cumming:
> > No, whenever a C object is destroyed, the C++ instance _will_ be deleted.
> > It
> > might not be obvious how that happens, though I have tried to add verbose
> > and
> > repetitive comments about that kind of thing.
> 
> You must be wrong. It has always been possible to have gtkmm widgets
> on the stack.

The statements are not incompatible. If the C++ object is on the stack (for
instance a class member variable) then the underlying C object will not be
destroyed before the C++'s destructor runs. It's the same when you use
new/delete. If it's not manage()ed then noone but the C++ destructor should
cause destruction of the underlying C object.


> And sure enough, in Object::destroy_notify_() which gets executed
> when the c instance dies, "delete this" is not reached when
> "referenced_ == true" (i.e. when the object has not been manage()ed):

If you think you've found a problem with the memory mangement please give me a
test case that proves it. We have identified and fixed a few problems recently
and those test cases are in the distribution in the tests directory.

I do plan to write up a detailed description of the C-C++ lifetime connection
- that's why I added the //GTKMM_LIFECYCLE comments. But it isn't a priority
at the moment.


Murray Cumming
murrayc usa net
www.murrayc.com




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