I have a Windows graphic program on MDI, MFC and Document has a 'wxr' object.
The WXR have a CtypedPtrList<CPtrList, CBackground *> OBList.
OBList* m_pList;
And CBackground has a CString members.
CString m_projectPathName;
CString m_projectName;
The program have a Error when close the program during Debugging.
is This Error has a relation with CString Object? I Hope to know.
The Destroyer order is like this as you know...
~Document() ->> ~WXR() ->> ~CBackground()
call stack ls like this.
CStringData::Release() line 86
..
CBackground::~CBackground() line end of destroyer
WXR::~WXR() // position of delete backgroundDestroyer
What I have tried:
WXR::~WXR()
{
....
pos = m_pList.GetHeadPosition();
while(pos != NULL){
delete m_pList.GetNext(pos); // <<== error point. view a call stack
}
m_pList.RemoveAll();
....
}
//CBackground
CBackground::~CBackground()
{
POSITION = NULL;
if(pBuf != NULL) // BYTE* pBuf;
pBuf = NULL;
}
//And CStringData::Release() Line 86
struct CStringData
{
.....
void Release() throw()
{
ATLASSERT( nRefs != 0 ); << == The Point Debugging Error! view a call stack
if( _InterlockedDecrement( &nRefs ) <= 0 )
{
pStringMgr->Free( this );
}
}
Thanks Your Time!