Home » Extra libraries, Code snippets, applications etc. » OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc » What happens with the virtual function PreDestroy in Linux?
What happens with the virtual function PreDestroy in Linux? [message #5417] |
Wed, 20 September 2006 16:14 ![Go to next message Go to next message](theme/default/images/down.png) |
nicomesas
Messages: 104 Registered: September 2006 Location: Barcelona, Spain
|
Experienced Member |
|
|
I don't know what happens with the virtual function PreDestroy in Linux.
It hoped that when my TopWindow is closed outside call by defect but does not happen thus.
Been I have observed in code in the Windows version and see that the function void Ctrl::WndDestroy() in CtrlCore/Win32Wnd.cpp makes a call to ::DestroyWindow(top->hwnd); this call generates a message that is gathered by function Ctrl::WindowProc in CrtlCore/Win32Proc.cpp
case WM_DESTROY:
PreDestroy();
But the Linux version of Ctrk::WndDestroy() does not invoke to that function of any way.
Well, finally I don't worry because the code to finalize I can put it in the destructor but it is to me rare that any call to that virtual function does not become.
Perhaps could be put a call to PreDestroy() at the end of the function Ctrl::WndDestroy() in linux?
Nico
|
|
|
|
|
Re: What happens with the virtual function PreDestroy in Linux? [message #5448 is a reply to message #5447] |
Fri, 22 September 2006 00:32 ![Go to previous message Go to previous message](theme/default/images/up.png) |
![](https://www.ultimatepp.org/forums/images/custom_avatars/3.png) |
mirek
Messages: 14003 Registered: November 2005
|
Ultimate Member |
|
|
nicomesas wrote on Thu, 21 September 2006 18:25 | OK
Then, he is correct to use the destructor to make this type of things?
class someThing : public TopWindow
{
MySqlSession mySql ;
someThing()
{
mySql.Connect(...........) ;
}
virtual ~someThing()
{
mySql.Close() ;
}
}
I believe that still I have Windows mentality and I do not finish thinking that can do this and be to me so calm, but in fact works.
UPP is great
Nico
|
Actually, it is unnecessary. MySqlSession destructor Closes the connection itself, you do not have to care about it.
BTW, this is very basic U++ design: All resources *owned* by object are always released/finalized when the object is destroyed (but you can release them sooner). Applies e.g. to files, sockets, printer jobs etc, etc.. This is what makes U++ development superior to GC based systems.
|
|
|
Goto Forum:
Current Time: Sun Sep 01 07:21:48 CEST 2024
Total time taken to generate the page: 0.00567 seconds
|