I'm having a Segmentation Fault when I call .begin() or .clear() on a std::list.
I'm working on a list which has a simple goal: to store some GUI elements that have to be freshened up.
The list is as follows:
list<ControllableUI*> uiToRefresh;
The functions acting on it are:
void SynthEngine::addUIToRefresh(ControllableUI* ui){
uiToRefresh.push_back(ui);
}
void SynthEngine::removeUIToRefresh(ControllableUI* ui){
list<ControllableUI*>::iterator i;
for(i=uiToRefresh.begin(); i != uiToRefresh.end();){
if((*i) == ui){
i = uiToRefresh.erase(i);
}
else {
++i;
}
}
}
void SynthEngine::refreshUI(){
list<ControllableUI*>::iterator i;
for(i=uiToRefresh.begin(); i != uiToRefresh.end();){
(*i)->refresh();
i = uiToRefresh.erase(i);
}
}
I'm calling removeUIToRefresh() whenever a UI component is deleted, to be sure it wont be called and start a segmentation fault, but it is this call that sends this error:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffefb4a700 (LWP 24071)]
0x00000000004a948e in std::list::begin (this=0x45a8) at /usr/include/c++/4.9/bits/stl_list.h:772 772 { return iterator(this->_M_impl._M_node._M_next); }
Are there some obvious reasons that can throw a segmentation fault using lists?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire