bugfix: properly remove remaining events of terminating experiment
Before this commit, EventList::getEventsOf() broke when *two* experiment flows terminated in direct succession: (*it)->getParent() fails if the underlying event doesn't exist anymore. To fix this, I moved the event removal from SimulatorController to EventList::remove(flow), and made it work on the internal event list magic similarly to EventList::remove(event). And I tested it with a few known-working experiments. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1022 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -51,14 +51,34 @@ EventList::iterator EventList::m_remove(iterator it, bool skip_deletelist)
|
||||
return (m_BufferList.erase(it));
|
||||
}
|
||||
|
||||
void EventList::getEventsOf(ExperimentFlow* pWhat,
|
||||
std::vector<BaseEvent*>& dest) const
|
||||
void EventList::remove(ExperimentFlow* flow)
|
||||
{
|
||||
assert(pWhat && "FATAL ERROR: The context cannot be NULL!");
|
||||
for(bufferlist_t::const_iterator it = m_BufferList.begin();
|
||||
it != m_BufferList.end(); it++)
|
||||
if((*it)->getParent() == pWhat)
|
||||
dest.push_back(*it);
|
||||
// all events?
|
||||
if (flow == 0) {
|
||||
m_BufferList.clear();
|
||||
} else {
|
||||
for (bufferlist_t::iterator it = m_BufferList.begin();
|
||||
it != m_BufferList.end(); ) {
|
||||
if ((*it)->getParent() == flow) {
|
||||
it = m_BufferList.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
// events that just fired / are about to fire ...
|
||||
for (firelist_t::const_iterator it = m_FireList.begin();
|
||||
it != m_FireList.end(); it++) {
|
||||
if (std::find(m_DeleteList.begin(), m_DeleteList.end(), *it)
|
||||
!= m_DeleteList.end()) {
|
||||
continue;
|
||||
}
|
||||
// ... need to be pushed into m_DeleteList, as we're currently
|
||||
// iterating over m_FireList in fireActiveEvents() and cannot modify it
|
||||
if (flow == 0 || (*it)->getParent() == flow) {
|
||||
m_DeleteList.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EventList::~EventList()
|
||||
|
||||
Reference in New Issue
Block a user