Click here to Skip to main content
14,177,305 members
Rate this:
 
Please Sign up or sign in to vote.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190526.1 | Last Updated 17 Jun 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100