From fc50bd9bade10a2b92f557af021731088b884104 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 14 Apr 2021 16:13:40 -0300 Subject: [PATCH] Move hard reset handling to the pc thread to avoid thread safety issues with GUI-triggered hard resets --- src/86box.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/86box.c b/src/86box.c index 16c99851a..6fb7541a7 100644 --- a/src/86box.c +++ b/src/86box.c @@ -175,6 +175,7 @@ int scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ int config_changed; /* config has changed */ int title_update; int framecountx = 0; +int hard_reset_pending = 0; int unscaled_size_x = SCREEN_RES_X; /* current unscaled size X */ @@ -856,9 +857,7 @@ pc_reset_hard_init(void) void pc_reset_hard(void) { - pc_reset_hard_close(); - - pc_reset_hard_init(); + hard_reset_pending = 1; } @@ -936,6 +935,13 @@ pc_run(void) { wchar_t temp[200]; + /* Trigger a hard reset if one is pending. */ + if (hard_reset_pending) { + hard_reset_pending = 0; + pc_reset_hard_close(); + pc_reset_hard_init(); + } + /* Run a block of code. */ startblit(); cpu_exec(cpu_s->rspeed / 100);