Skip to content

Commit

Permalink
Avoid cyclic iteration check, fixes #24969
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jan 22, 2019
1 parent c70c43c commit 0c9fd3c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,13 +1789,21 @@ 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;
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);
Expand Down Expand Up @@ -1923,6 +1931,8 @@ bool Main::iteration() {
frames = 0;
}

iterating = false;

if (fixed_fps != -1)
return exit;

Expand Down
3 changes: 3 additions & 0 deletions main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -58,6 +59,8 @@ class Main {
static bool iteration();
static void force_redraw();

static bool is_iterating();

static void cleanup();
};

Expand Down
4 changes: 3 additions & 1 deletion platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ - (void)windowDidResize:(NSNotification *)notification {
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();
}
}

/*
Expand Down
4 changes: 3 additions & 1 deletion platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0c9fd3c

Please sign in to comment.