Unsubscribe SDL input modules from events on exit.

This commit is contained in:
Brad Hughes 2016-03-30 17:24:29 -04:00
parent b755be89a6
commit 2b0cc65dba
2 changed files with 15 additions and 3 deletions

View File

@ -435,6 +435,14 @@ public:
}
}
void exit() override
{
// unsubscribe for events
sdl_event_manager::instance().unsubscribe(this);
input_module_base::exit();
}
void before_poll(running_machine& machine) override
{
// Tell the event manager to process events and push them to the devices

View File

@ -96,12 +96,16 @@ public:
std::lock_guard<std::mutex> scope_lock(m_lock);
// Loop over the entries and find ones that match our subscriber
// remove those that match
for (auto iter = m_subscription_index.begin(); iter != m_subscription_index.end(); iter++)
std::vector<typename std::unordered_multimap<int, TSubscriber*>::iterator> remove;
for (auto iter = m_subscription_index.begin(); iter != m_subscription_index.end(); ++iter)
{
if (iter->second == subscriber)
m_subscription_index.erase(iter);
remove.push_back(iter);
}
// remove those that matched
for (int i = 0; i < remove.size(); i++)
m_subscription_index.erase(remove[i]);
}
virtual void process_events(running_machine &machine) = 0;