Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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
nicomesas is currently offline  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 #5445 is a reply to message #5417] Thu, 21 September 2006 21:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Please consider PreDestroy as internal implementation feature. You should not normally need to use it.
Re: What happens with the virtual function PreDestroy in Linux? [message #5447 is a reply to message #5445] Fri, 22 September 2006 00:25 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
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 Smile

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
mirek is currently offline  mirek
Messages: 13975
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 Smile

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.
Previous Topic: Microsoft Visual C++ workspace
Next Topic: Rare behavior in Windows
Goto Forum:
  


Current Time: Thu Mar 28 20:13:00 CET 2024

Total time taken to generate the page: 0.01493 seconds