Print Page | Close Window

CXTPCommandBarsSiteBase memory leak

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=15381
Printed Date: 14 May 2024 at 9:42pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPCommandBarsSiteBase memory leak
Posted By: znakeeye
Subject: CXTPCommandBarsSiteBase memory leak
Date Posted: 16 October 2009 at 5:04am
XTP 12.0.1, but I think this is present in all versions.
 
class CMyPane : public CXTPFrameWndBase<CWnd>
...
int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CXTPFrameWndBase<CWnd>::OnCreate(lpCreateStruct) == -1)
         return -1;

    InitCommandBars();
    ...
}
 
In my application this window is created, destroyed and then created again - without destroying the CMyPane-object:
 
m_myPane.Destroy();
...
m_myPane.Create(...); // MEMORY LEAK!
 
 
The error lies in XTPFrameWnd.h. Obviously, you don't think about the above scenario!
virtual BOOL InitCommandBars(CRuntimeClass* pCommandBarsClass = RUNTIME_CLASS(CXTPCommandBars))
 {
    // Begin FIX
    if (m_pCommandBars)
    {
        m_pCommandBars->InternalRelease();
    }
    // End FIX
    ASSERT(pCommandBarsClass->IsDerivedFrom(RUNTIME_CLASS(CXTPCommandBars)));
    m_pCommandBars =  (CXTPCommandBars*) pCommandBarsClass->CreateObject();
    ASSERT(m_pCommandBars);
    if (!m_pCommandBars)
        return FALSE;
    m_pCommandBars->SetSite(this);
    m_pCommandBars->EnableDocking();
    return TRUE;
}


-------------
PokerMemento - http://www.pokermemento.com/



Replies:
Posted By: znakeeye
Date Posted: 16 October 2009 at 5:07am
Hmmm, why not destroy the command-bar in OnDestroy()?

-------------
PokerMemento - http://www.pokermemento.com/


Posted By: Oleg
Date Posted: 16 October 2009 at 5:23am
Hi,
 
Thanks, indeed we didn't catch such scenario. I will add same fix code.

Thanks.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: terrym
Date Posted: 16 October 2009 at 7:50am
Did this make fix for 13.2?


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: Oleg
Date Posted: 18 October 2009 at 1:27am
yes, sure.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: terrym
Date Posted: 18 October 2009 at 4:42am
Excellent

-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey



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