Fixed two music bot hangups
This commit is contained in:
@@ -30,9 +30,12 @@ void AbstractMusicPlayer::unregisterEventHandler(const std::string& string) {
|
||||
}
|
||||
|
||||
void AbstractMusicPlayer::fireEvent(MusicEvent event) {
|
||||
std::lock_guard lock(this->eventLock);
|
||||
auto listCopy = this->eventHandlers; //Copy for remove while fire
|
||||
for(const auto& entry : listCopy)
|
||||
decltype(this->eventHandlers) handlers{};
|
||||
{
|
||||
std::lock_guard lock(this->eventLock);
|
||||
handlers = this->eventHandlers; //Copy for remove while fire
|
||||
}
|
||||
for(const auto& entry : handlers)
|
||||
entry.second(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user