question about destructors
Brought to you by:
set
From: <pet...@se...> - 2006-02-28 19:52:09
|
Is there any reason why TGroup::~TGroup() doesn't call shutDown()? I'd post it as bug, but it's so obvious that more likely there is some really good reason that I don't see (wrong chaining of destructors with some non-gcc compilers? I don't have too much experience with portability in obscure environments, just gcc on linux and mingw). By looking into other TV clones on the net it may be legacy from the original borland source, but you said you don't aim to be 100% compatible and besides changing it shouldn't bring any incompatibility. I know TV from ancient times when I worked in pascal. Recently I needed to code UI for console applications so I looked for c++ counterpart to TV I already knew, found this and did what I remembered as correct: { TDialog *dlg; TProgram::deskTop->execView(dlg); delete dlg; } After coding 4 dialogs I thought that it's time to wonder if I have memory management right, and of course I found that each dialog instance uses ~4kB memory which is not returned. And after little searching I found that the correct way is to call CLY_destroy(dlg) instead of standard c++ way of using destructors. Even Borland manual for destructor TGroup.done() (for pascal, I don't have one for c++ TV) says "Hides the group using Hide, disposes of each subview in the group, and finally calls the Done destructor inherited from TView" in the description of TGroup destructor. As simple fix I added the call to shutDown() into ~TView() and ~TGroup and the basic dialogs now work as I expected (I didn't have lot of time to test it yet - it just compiles, runs and valgrind reports no leaks in views). I can get a patch together if you are interested, after fixing rest of shutDown()'s. And testing it a bit. |