Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Minor coding error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Minor coding error

 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: Minor coding error
    Posted: 15 April 2009 at 3:39am

BOOL CXTPPropertySheet::AddButton(UINT nIDCaption, UINT nID)
{
 CString strButton;
 CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strButton, nIDCaption));

 CButton* pButton = new CButton();
 if (!pButton->Create(strButton, WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, CRect(0, 0, 0, 0), this, nID))
  return FALSE;

Shouldn't happen, but if it does there will be a leak...

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: 15 April 2009 at 4:25am
Thanks.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 15 April 2009 at 6:01am
Originally posted by znakeeye znakeeye wrote:

BOOL CXTPPropertySheet::AddButton(UINT nIDCaption, UINT nID)
{
 CString strButton;
 CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strButton, nIDCaption));

 CButton* pButton = new CButton();
 if (!pButton->Create(strButton, WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, CRect(0, 0, 0, 0), this, nID))
  return FALSE;

Shouldn't happen, but if it does there will be a leak...



Shouldn't that be
if (!pButton || !pButton->Create(...))

Codejock support
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 15 April 2009 at 5:24pm
Hi;

I thought nowadays operator new throws a std::bad_alloc exception...
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 16 April 2009 at 7:03am
Originally posted by mgampi mgampi wrote:

Hi;

I thought nowadays operator new throws a std::bad_alloc exception...


http://support.microsoft.com/?scid=kb%3Ben-us%3B167733&x=21&y=11

Codejock support
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.156 seconds.