summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Brad Hughes <bradhugh@outlook.com>2016-03-30 17:24:29 -0400
committer Brad Hughes <bradhugh@outlook.com>2016-03-30 17:24:29 -0400
commit2b0cc65dba2465218cdfa0e88e37d9f3d11ff203 (patch)
tree8341b6b1e9aa235c9914b17c5488cf0b17d1b4d2
parentb755be89a626254020b43bf9255817c3ada524bc (diff)
Unsubscribe SDL input modules from events on exit.
-rw-r--r--src/osd/modules/input/input_sdl.cpp8
-rw-r--r--src/osd/modules/input/input_sdlcommon.h10
2 files changed, 15 insertions, 3 deletions
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index 9ea26733f60..2c5b2e45a8c 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -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
diff --git a/src/osd/modules/input/input_sdlcommon.h b/src/osd/modules/input/input_sdlcommon.h
index 3650a313e9d..458b90be7ba 100644
--- a/src/osd/modules/input/input_sdlcommon.h
+++ b/src/osd/modules/input/input_sdlcommon.h
@@ -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;