LCOV - code coverage report
Current view: top level - src/gui - crash_recovery_ui.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 15.4 % 13 2
Test Date: 2026-06-01 11:15:25 Functions: 100.0 % 1 1

            Line data    Source code
       1              : #pragma once
       2              : #include <SDL.h>
       3              : 
       4              : /**
       5              :  * @brief Displays a native modal popup to ask the user if they wish to restore 
       6              :  * the previous session after a crash.
       7              :  * * @return true if the user clicks "Restore", false if "Discard".
       8              :  */
       9              : 
      10           12 : inline bool promptRestoreSession() {
      11              : #if defined(__EMSCRIPTEN__) || defined(AMPLITRON_HEADLESS)
      12              :     // Blocking message boxes not supported in WebAssembly or headless test builds.
      13           12 :     return false;
      14              : #else
      15            0 :     if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
      16            0 :         if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) return false;
      17            0 :     }
      18              : 
      19            0 :     const SDL_MessageBoxButtonData buttons[] = {
      20              :         { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "Restore" },
      21              :         { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "Discard" },
      22              :     };
      23              :     
      24            0 :     const SDL_MessageBoxData messageboxdata = {
      25              :         SDL_MESSAGEBOX_WARNING,
      26              :         nullptr,
      27              :         "Amplitron Recovery",
      28              :         "Amplitron closed unexpectedly during your last session.\n\n"
      29              :         "Would you like to restore your previous pedal chain configuration?",
      30              :         SDL_arraysize(buttons),
      31            0 :         buttons,
      32              :         nullptr
      33            0 :     };
      34              :     
      35            0 :     int buttonid;
      36            0 :     if (SDL_ShowMessageBox(&messageboxdata, &buttonid) < 0) return false;
      37            0 :     return buttonid == 1;
      38              : #endif
      39            0 : }
        

Generated by: LCOV version 2.0-1