Print Page | Close Window

You declared a destructor as non-virtual

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5676
Printed Date: 23 November 2024 at 9:07am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: You declared a destructor as non-virtual
Posted By: Sergio
Subject: You declared a destructor as non-virtual
Date 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



Replies:
Posted By: Sergio
Date Posted: 04 December 2006 at 9:20am
P.S. : Same problem for the class CXTPCommandBarsSiteBase

-------------
Sergio


Posted By: Oleg
Date 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


Posted By: Sergio
Date 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


Posted By: Sergio
Date 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


Posted By: Oleg
Date 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


Posted By: Sergio
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net