Merge pull request #709 from jyrkive/fix-event-context-crash

Fix undefined behavior on destroying an event context
This commit is contained in:
Andreas 2016-07-23 11:09:34 +12:00 committed by GitHub
commit b9b97bab84

View File

@ -132,15 +132,15 @@ void context::set_focus(const sdl_handler* ptr)
context::~context() context::~context()
{ {
if (!handlers.empty()) { for (sdl_handler* h : handlers)
for (handler_list::iterator it = handlers.begin(); it != handlers.end(); ++it) { {
if ((*it)->has_joined()) { if (h->has_joined())
(*it)->has_joined_ = false; {
} h->has_joined_ = false;
if ((*it)->has_joined_global()) { }
(*it)->has_joined_global_ = false; if (h->has_joined_global())
} {
it = handlers.erase(it); h->has_joined_global_ = false;
} }
} }
} }