diff options
-rw-r--r-- | main/main.cpp | 10 | ||||
-rw-r--r-- | main/main.h | 3 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 4 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 4 |
4 files changed, 19 insertions, 2 deletions
diff --git a/main/main.cpp b/main/main.cpp index cbf30af38c..b94130002d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1789,6 +1789,10 @@ uint64_t Main::target_ticks = 0; uint32_t Main::frames = 0; uint32_t Main::frame = 0; bool Main::force_redraw_requested = false; +bool Main::iterating = false; +bool Main::is_iterating() { + return iterating; +} // For performance metrics static uint64_t physics_process_max = 0; @@ -1796,6 +1800,10 @@ static uint64_t idle_process_max = 0; bool Main::iteration() { + ERR_FAIL_COND_V(iterating, false); + + iterating = true; + uint64_t ticks = OS::get_singleton()->get_ticks_usec(); Engine::get_singleton()->_frame_ticks = ticks; main_timer_sync.set_cpu_ticks_usec(ticks); @@ -1923,6 +1931,8 @@ bool Main::iteration() { frames = 0; } + iterating = false; + if (fixed_fps != -1) return exit; diff --git a/main/main.h b/main/main.h index 01fc259a8a..1bdce7d17f 100644 --- a/main/main.h +++ b/main/main.h @@ -47,6 +47,7 @@ class Main { static uint32_t frames; static uint32_t frame; static bool force_redraw_requested; + static bool iterating; public: static bool is_project_manager(); @@ -58,6 +59,8 @@ public: static bool iteration(); static void force_redraw(); + static bool is_iterating(); + static void cleanup(); }; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index ddd98ab88c..760858b2e5 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -304,7 +304,9 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto if (OS_OSX::singleton->main_loop) { Main::force_redraw(); //Event retrieval blocks until resize is over. Call Main::iteration() directly. - Main::iteration(); + if (!Main::is_iterating()) { //avoid cyclic loop + Main::iteration(); + } } /* diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3b41f1b901..d1693cb0b4 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -783,7 +783,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_TIMER: { if (wParam == move_timer_id) { process_key_events(); - Main::iteration(); + if (!Main::is_iterating()) { + Main::iteration(); + } } } break; |