diff --git a/gtk3/console_window.c b/gtk3/console_window.c index 66f7abe..a36cfc4 100644 --- a/gtk3/console_window.c +++ b/gtk3/console_window.c @@ -507,3 +507,10 @@ void break_debugger(ConsoleWindow *self) { gtk_window_present_with_time(GTK_WINDOW(self), time(NULL)); gtk_widget_grab_focus(GTK_WIDGET(self->input)); } + +// Hack to avoid deadlocking on queue reads ... +void abort_debugger(ConsoleWindow *self) { + g_async_queue_push(self->input_queue, g_strdup("c\0")); + g_async_queue_push(self->output_queue, g_strdup("c\0")); + console_clear(self); +} diff --git a/gtk3/console_window.h b/gtk3/console_window.h index 2fd03d0..386269b 100644 --- a/gtk3/console_window.h +++ b/gtk3/console_window.h @@ -13,4 +13,5 @@ char *console_get_sync_input(ConsoleWindow *self, GB_gameboy_t *gb); void console_log(ConsoleWindow *self, const char *message, GB_log_attributes attributes); void console_clear(ConsoleWindow *self); void break_debugger(ConsoleWindow *self); +void abort_debugger(ConsoleWindow *self); #endif \ No newline at end of file diff --git a/gtk3/main.c b/gtk3/main.c index 97b7d1d..78a4da1 100644 --- a/gtk3/main.c +++ b/gtk3/main.c @@ -435,12 +435,13 @@ static void stop(void) { GB_audio_set_paused(true); GB_debugger_set_disabled(&gb, true); - if (GB_debugger_is_stopped(&gb)) { - // [self interruptDebugInputRead]; - } - gui_data.stopping = true; gui_data.running = false; + + if (GB_debugger_is_stopped(&gb)) { + abort_debugger(gui_data.console); + } + while (gui_data.stopping); GB_debugger_set_disabled(&gb, false);