Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CXTPCommandBarsSiteBase memory leak
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPCommandBarsSiteBase memory leak

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

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: CXTPCommandBarsSiteBase memory leak
    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/
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2009 at 5:07am
Hmmm, why not destroy the command-bar in OnDestroy()?
PokerMemento - http://www.pokermemento.com/
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: 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
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post 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
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: 18 October 2009 at 1:27am
yes, sure.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post Posted: 18 October 2009 at 4:42am
Excellent
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey
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.