Re: Check on correctness
- From: "tim@xxxxxxxxxxxxxxxxxxxxxx" <tim@xxxxxxxxxxxxxx>
- Date: 1 Jul 2006 05:21:56 -0700
Thanks for the reply, sheesh what a chump.
Yours...one step closer to being a decent developer.
Tim
www.fruitfruit.com wrote:
I had a problem with CMyView->GetDocument() in release.That is due to the fact that ASSERT is ignored in release configuration.
Within the constructor of the dialog class, I assigned the attribute,
m_pDoc to the document
ASSERT(m_pDoc = pParent->GetDocument());
In release, my program would throw an exception because m_pDoc was
NULL. I trawled through google, to see this is a common error (also
reading that I should call GetDocument every time rather than assigning
to an attribute).
However, if I assign m_pDoc within the dialog's initialisation list the
attribute is assigned correctly.
CExternalEffectorDlg::CExternalEffectorDlg(CState_SdiView*
pParent,const int AtomIndex)
: CDialog( CExternalEffectorDlg::IDD, pParent ),
m_pDoc( pParent->GetDocument() ),
Is calling a getter in an initialisation list bad practice?
You shall not put initialize code in ASSERT, do it in the following way:
m_pDoc = pParent->GetDocument();
ASSERT(m_pDoc);
This shall work for both Debug and Release.
.
- Follow-Ups:
- Re: Check on correctness
- From: Joseph M . Newcomer
- Re: Check on correctness
- References:
- Check on correctness
- From: tim@xxxxxxxxxxxxxxxxxxxxxx
- Re: Check on correctness
- From: www.fruitfruit.com
- Check on correctness
- Prev by Date: Re: Check on correctness
- Next by Date: Re: issue with dialog
- Previous by thread: Re: Check on correctness
- Next by thread: Re: Check on correctness
- Index(es):
Relevant Pages
|
Loading