diff --git a/src/menu_item.cpp b/src/menu_item.cpp index d24f9b7..5c42446 100644 --- a/src/menu_item.cpp +++ b/src/menu_item.cpp @@ -261,7 +261,6 @@ MenuItemRoot::MenuItemRoot(const std::vector> &suites #ifdef DISABLE_AUTORUN submenu.push_back(std::make_shared(on_run_all, "! Run all and exit", width, height)); #endif // DISABLE_AUTORUN - start_time = std::chrono::high_resolution_clock::now(); } void MenuItemRoot::ActivateCurrentSuite() { @@ -270,6 +269,11 @@ void MenuItemRoot::ActivateCurrentSuite() { } void MenuItemRoot::Draw() { + if (!timer_valid) { + start_time = std::chrono::high_resolution_clock::now(); + timer_valid = true; + } + #ifndef DISABLE_AUTORUN if (!timer_cancelled) { auto now = std::chrono::high_resolution_clock::now(); @@ -388,16 +392,19 @@ MenuItemOptions::MenuItemOptions(const std::vector> & }; submenu.push_back(std::make_shared("Previous crashes", values, on_apply)); } - - start_time = std::chrono::high_resolution_clock::now(); } void MenuItemOptions::Draw() { + if (!timer_valid) { + start_time = std::chrono::high_resolution_clock::now(); + timer_valid = true; + } if (!timer_cancelled) { auto now = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast(now - start_time).count(); if (elapsed > kAutoTestAllTimeoutMilliseconds) { - on_exit(); + cursor_position = 0; + Activate(); return; } diff --git a/src/menu_item.h b/src/menu_item.h index adeec54..9bf130c 100644 --- a/src/menu_item.h +++ b/src/menu_item.h @@ -112,6 +112,7 @@ struct MenuItemRoot : public MenuItem { std::function on_run_all; std::function on_exit; std::chrono::steady_clock::time_point start_time; + bool timer_valid{false}; bool timer_cancelled{false}; }; @@ -130,6 +131,7 @@ struct MenuItemOptions : public MenuItem { std::function on_exit; std::chrono::steady_clock::time_point start_time; + bool timer_valid{false}; bool timer_cancelled{false}; };