mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Fixed another potential MessageQueue issue. This should be the last one.
This commit is contained in:
parent
d628fabf71
commit
a4683e08f5
@ -112,7 +112,12 @@ void MessageQueue::Dispatch() {
|
||||
EnqueuedMessage *m = (*it);
|
||||
|
||||
if (now >= m->time) {
|
||||
this->dispatch.push_back(m);
|
||||
/* it's possible the target (receiver) has been unregistered;
|
||||
if that's the case, just discard it. otherwise, add it to the
|
||||
output set to be dispatched outside of the critical section */
|
||||
if (this->targets.find((*it)->message->Target()) != this->targets.end()) {
|
||||
this->dispatch.push_back(m);
|
||||
}
|
||||
it = this->queue.erase(it);
|
||||
}
|
||||
else {
|
||||
@ -125,9 +130,7 @@ void MessageQueue::Dispatch() {
|
||||
|
||||
Iterator it = this->dispatch.begin();
|
||||
while (it != this->dispatch.end()) {
|
||||
if (this->targets.find((*it)->message->Target()) != this->targets.end()) {
|
||||
this->Dispatch((*it)->message);
|
||||
}
|
||||
this->Dispatch((*it)->message);
|
||||
delete *it;
|
||||
it++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user