Click here to Skip to main content
11,718,016 members (73,758 online)

C / C++ / MFC

 
QuestionI am Bemused about std::list<> Pin
yu-jian13-Nov-12 4:17
groupyu-jian13-Nov-12 4:17 
// Define 
std::list<SMyFrameData*>    m_FrameList;
CCriticalSection	m_FrameListLock;
... 
 
        //Pop the frame data from the font of list.
	CTempLock tempLock(&m_FrameListLock);
	if (m_FrameList.size() == 0) return 0L;
 
	pFrameData = m_FrameList.front();
	m_FrameList.pop_front();
        ... Decoder the frame data

        // use following code to push the frame data to the list.
        SMyFrameData* pNewFrame = new SMyFrameData();
pNewFrame->lpData = pBuf;
pNewFrame->iSize    =   iSize;
 
CTempLock (&(pProcess->m_FrameListLock));
pProcess->m_FrameList.push_back(pNewFrame);
SetEvent(pProcess->m_hFrameProcessEvent);

But now there is a error happen "erators and references can become invalid." in code, pFrameData = m_FrameList.front(); I just use the CCriticalSection to avoid the conflict, but why the error happen.
AnswerRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 5:37
mvpRichard MacCutchan13-Nov-12 5:37 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 6:03
memberStephen Hewitt13-Nov-12 6:03 
GeneralRe: I am Bemused about std::list<> Pin
yu-jian13-Nov-12 6:25
groupyu-jian13-Nov-12 6:25 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 6:38
mvpRichard MacCutchan13-Nov-12 6:38 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 15:04
memberStephen Hewitt13-Nov-12 15:04 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 20:59
mvpRichard MacCutchan13-Nov-12 20:59 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 23:54
memberStephen Hewitt13-Nov-12 23:54 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 23:58
mvpRichard MacCutchan13-Nov-12 23:58 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 0:58
memberStephen Hewitt14-Nov-12 0:58 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 1:30
mvpRichard MacCutchan14-Nov-12 1:30 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 2:06
memberStephen Hewitt14-Nov-12 2:06 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 2:26
mvpRichard MacCutchan14-Nov-12 2:26 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 2:30
memberStephen Hewitt14-Nov-12 2:30 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 3:36
mvpRichard MacCutchan14-Nov-12 3:36 
GeneralRe: I am Bemused about std::list<> Pin
DavidCrow14-Nov-12 3:16
memberDavidCrow14-Nov-12 3:16 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 3:32
mvpRichard MacCutchan14-Nov-12 3:32 
GeneralRe: I am Bemused about std::list<> Pin
yu-jian13-Nov-12 6:25
groupyu-jian13-Nov-12 6:25 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 6:43
mvpRichard MacCutchan13-Nov-12 6:43 
QuestionRe: I am Bemused about std::list<> Pin
DavidCrow13-Nov-12 8:05
memberDavidCrow13-Nov-12 8:05 
AnswerRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 15:13
memberStephen Hewitt13-Nov-12 15:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 3 Sep 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid