Print Page | Close Window

Minor coding error

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=14023
Printed Date: 27 September 2024 at 11:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Minor coding error
Posted By: znakeeye
Subject: Minor coding error
Date 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/



Replies:
Posted By: Oleg
Date Posted: 15 April 2009 at 4:25am
Thanks.

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


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


Posted By: mgampi
Date Posted: 15 April 2009 at 5:24pm
Hi;

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


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: ABuenger
Date 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 - http://support.microsoft.com/?scid=kb%3Ben-us%3B167733&x=21&y=11



-------------
Codejock support



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