Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Memory Leaks?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Memory Leaks?

 Post Reply Post Reply
Author
Message
martypku View Drop Down
Newbie
Newbie


Joined: 17 September 2006
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote martypku Quote  Post ReplyReply Direct Link To This Post Topic: Memory Leaks?
    Posted: 17 September 2006 at 10:02pm

Version:8.7

VC6.0, SP6
 
I add the following code to CMainFrame::OnCreate to dynamically add a menu at run-time:
 
CXTPPopupBar *pBar = (CXTPPopupBar*) CXTPPopupBar::CreatePopupBar(GetCommandBars());
 CXTPControlPopup * pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
 pControlPopup->SetCommandBar(pBar);
 pControlPopup->SetCaption("Test");
 pControlPopup->SetEnabled(TRUE);
 CXTPControl * pControl = GetCommandBars()->GetMenuBar()->GetControls()->Add(pControlPopup, -1, "", -1, FALSE);

 
VC reported memory leaks:
a CXTPControls object at $0003EDA0, 64 bytes long
a CXTPPopupBar object at $03037260, 408 bytes long
 
What's wrong?
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 September 2006 at 3:53am
Hi,
 
After this code add
pBar ->InternalRelease();
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
martypku View Drop Down
Newbie
Newbie


Joined: 17 September 2006
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote martypku Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2006 at 4:49am
Thanks! It works!
How can I know I must release an object by myself?
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 September 2006 at 5:09am
It's one of exceptional situation in toolkit. because same popup bar can be assigned for different popup controls:
 
CXTPPopupBar *pBar = (CXTPPopupBar*) CXTPPopupBar::CreatePopupBar(GetCommandBars());

 pControlPopup1->SetCommandBar(pBar);
 pControlPopup2->SetCommandBar(pBar);
 
pBar ->InternalRelease();
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
martypku View Drop Down
Newbie
Newbie


Joined: 17 September 2006
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote martypku Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2006 at 6:02am

Did you mean:"Once I create a CXTPPopupBar and assign it to a popup control, I must release it"?

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 September 2006 at 9:05am
yes.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
martypku View Drop Down
Newbie
Newbie


Joined: 17 September 2006
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote martypku Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2006 at 9:26am
Thanks!
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.203 seconds.