Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - You declared a destructor as non-virtual
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

You declared a destructor as non-virtual

 Post Reply Post Reply
Author
Message
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Topic: You declared a destructor as non-virtual
    Posted: 04 December 2006 at 9:18am
Hello,
 
It seems that you have declared a destructor as non-virtual, all our classes derived from CXTPFrameWndBase do not have their destructor called, thus making some memory leaks to our objects.
 
Here is your code :
 
 
In your file "XTPFrameWnd.h" :

class CXTPFrameWndBase : public CXTPCommandBarsSiteBase<TBase>
{
public:
    //-----------------------------------------------------------------------
    // Summary:
    //     Constructs a CXTPFrameWndBase object
    //-----------------------------------------------------------------------
    CXTPFrameWndBase()
    {
    }
    //-----------------------------------------------------------------------
    // Summary:
    //     Destroys a CXTPFrameWndBase object, handles cleanup and deallocation
    //-----------------------------------------------------------------------
    ~CXTPFrameWndBase() // !!!! Not virtual ???
    {
    }
...
 
 
Could you please check it and tell us if it is a bug ?
 
Thank you in advance,
Regards,
Sergio
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2006 at 9:20am
P.S. : Same problem for the class CXTPCommandBarsSiteBase
Sergio
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2006 at 10:57am
Hi,
it is not bug. All CWnd derived classes have virtual destuctors. virtual keyword doesn't requried.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2006 at 11:26am
Hi,
 
Ok, then do you know why our destructor of our CMDIChildWnd is never called ?
 
Here is our code :
 
 
#define CChildFrameBase CXTPFrameWndBase<CMDIChildWnd>
 
class CLASS_DECL_FCORE CFMDIChildWnd : public CChildFrameBase
{
       DECLARE_DYNCREATE(CFMDIChildWnd)
protected:
       CFMDIChildWnd();           // protected constructor used by dynamic creation
       virtual ~CFMDIChildWnd();
...
 
Perhaps it's due to missing DECLARE_DYNCREATE(...) ?
 
 
Sergio
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2006 at 11:42am

We have temporarily placed our cleanup code inside method OnDestroy (WM_DESTROY), to avoid memory leaks.

Please tell us if you have more information about this destructor.
 
Thanks !
Regards,
Sergio
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2006 at 1:05pm

It must be called from PostNcDestroy.. mey be override this method or something.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Posted: 11 December 2006 at 9:06am
Hi Oleg,
 
I finally found where was the problem. It isn't Codejock, it's our code :
 
        virtual void PostNcDestroy() {};   // in child.h
 
This is the method who calls "delete this;"...
 
Sorry for the disturb and thank you very much for your help,
Best regards,
Sergio
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.