Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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!
Posted
Updated 16-Jun-18 22:00pm
v3
Comments
Richard MacCutchan 17-Jun-18 4:19am    
Either your CString has been corrupted, or it has already been released somehow. You will need to trace your code some more to find out where this happens.
Chopin2001 17-Jun-18 5:18am    
Thanks R. McCutchan.
But as you can see I didn't entry CString members in ~Background() cause these are not pointer. I don't understand why this is Happened.
Richard MacCutchan 17-Jun-18 7:05am    
Sorry, I do not understand what that means. The error is clear, someone is trying to release an object more than once.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900