mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 06:29:58 -04:00
Write the log file before stderr, and keep a blocked console from stopping the log and the exit.
A selection in the console window of a game started directly held back the write to stderr, and with it the log file, the exit hook and the crash report. The log file now comes first, stderr goes past the C runtime's stream lock, and the lines of an exit, a fatal error or a crash skip stderr while another thread is stuck in it. A game run turns the console's QuickEdit mode off, and a closed console, Ctrl+C or Ctrl+Break ends the game the way a closed window does, with the settings and saves written and the exit logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,10 @@ void gfx_window_focus_changed(int in) {
|
||||
// (plat_restart), and the new process waits until this one is gone (main.c) before it moves the log and opens the
|
||||
// RomFS and the saves.
|
||||
void gfx_window_closed(void) {
|
||||
// Once. The console's close (main.c console_closed) can come beside the window's: the later caller waits here
|
||||
// while the first one saves and ends the process.
|
||||
static volatile int32_t closing;
|
||||
if (plat_xchg32(&closing, 1)) for (;;) plat_sleep_ms(1000);
|
||||
int restart = plat_cas32(&g_restart, 0, 0) != 0;
|
||||
rt_log("gfx: window closed; %s", restart ? "restarting" : "exiting");
|
||||
cfg_save(); // a menu change saves 400 ms later on the render thread (option_rows.cpp); closing sooner kept the old file
|
||||
|
||||
Reference in New Issue
Block a user