Avoid cyclic iteration check, fixes #24969

This commit is contained in:
Juan Linietsky 2019-01-22 13:17:39 -03:00
parent c70c43c888
commit 0c9fd3c4b4
4 changed files with 19 additions and 2 deletions

View File

@ -1789,6 +1789,10 @@ uint64_t Main::target_ticks = 0;
uint32_t Main::frames = 0; uint32_t Main::frames = 0;
uint32_t Main::frame = 0; uint32_t Main::frame = 0;
bool Main::force_redraw_requested = false; bool Main::force_redraw_requested = false;
bool Main::iterating = false;
bool Main::is_iterating() {
return iterating;
}
// For performance metrics // For performance metrics
static uint64_t physics_process_max = 0; static uint64_t physics_process_max = 0;
@ -1796,6 +1800,10 @@ static uint64_t idle_process_max = 0;
bool Main::iteration() { bool Main::iteration() {
ERR_FAIL_COND_V(iterating, false);
iterating = true;
uint64_t ticks = OS::get_singleton()->get_ticks_usec(); uint64_t ticks = OS::get_singleton()->get_ticks_usec();
Engine::get_singleton()->_frame_ticks = ticks; Engine::get_singleton()->_frame_ticks = ticks;
main_timer_sync.set_cpu_ticks_usec(ticks); main_timer_sync.set_cpu_ticks_usec(ticks);
@ -1923,6 +1931,8 @@ bool Main::iteration() {
frames = 0; frames = 0;
} }
iterating = false;
if (fixed_fps != -1) if (fixed_fps != -1)
return exit; return exit;

View File

@ -47,6 +47,7 @@ class Main {
static uint32_t frames; static uint32_t frames;
static uint32_t frame; static uint32_t frame;
static bool force_redraw_requested; static bool force_redraw_requested;
static bool iterating;
public: public:
static bool is_project_manager(); static bool is_project_manager();
@ -58,6 +59,8 @@ public:
static bool iteration(); static bool iteration();
static void force_redraw(); static void force_redraw();
static bool is_iterating();
static void cleanup(); static void cleanup();
}; };

View File

@ -304,8 +304,10 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
if (OS_OSX::singleton->main_loop) { if (OS_OSX::singleton->main_loop) {
Main::force_redraw(); Main::force_redraw();
//Event retrieval blocks until resize is over. Call Main::iteration() directly. //Event retrieval blocks until resize is over. Call Main::iteration() directly.
if (!Main::is_iterating()) { //avoid cyclic loop
Main::iteration(); Main::iteration();
} }
}
/* /*
_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); _GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);

View File

@ -783,8 +783,10 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_TIMER: { case WM_TIMER: {
if (wParam == move_timer_id) { if (wParam == move_timer_id) {
process_key_events(); process_key_events();
if (!Main::is_iterating()) {
Main::iteration(); Main::iteration();
} }
}
} break; } break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN: