Fixes freeze when starting new game or editor

Fixes freeze introduced by 9511f65 where event_process wouldn't go to the next window if it's hidden.
This commit is contained in:
Chris Taylor 2016-11-07 09:32:06 +08:00
parent b19e93cc04
commit b7bbb37885

View file

@ -161,21 +161,14 @@ window_event_result event_process(void)
return highest_result;
event.type = EVENT_WINDOW_DRAW; // then draw all visible windows
wind = window_get_first();
while (wind != NULL)
for (wind = window_get_first(); wind != nullptr; wind = window_get_next(*wind))
{
window *prev = window_get_prev(*wind);
if (window_is_visible(wind))
{
auto prev = window_get_prev(*wind);
auto result = window_send_event(*wind, event);
if (result == window_event_result::deleted)
{
if (!prev) // well there isn't a previous window ...
break; // ... just bail out - we've done everything for this frame we can.
wind = window_get_next(*prev); // the current window seemed to be closed. so take the next one from the previous which should be able to point to the one after the current closed
}
else
wind = window_get_next(*wind);
wind = prev; // take the previous window and get the next one from that (if prev isn't nullptr)
highest_result = std::max(result, highest_result);
}