[GTK3] Workaround for a deadlock when killing the program while the debugger is stopped

This commit is contained in:
Maximilian Mader 2021-01-02 17:40:42 +01:00
parent cc0827c429
commit a56a97d657
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
3 changed files with 13 additions and 4 deletions

View File

@ -507,3 +507,10 @@ void break_debugger(ConsoleWindow *self) {
gtk_window_present_with_time(GTK_WINDOW(self), time(NULL)); gtk_window_present_with_time(GTK_WINDOW(self), time(NULL));
gtk_widget_grab_focus(GTK_WIDGET(self->input)); 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);
}

View File

@ -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_log(ConsoleWindow *self, const char *message, GB_log_attributes attributes);
void console_clear(ConsoleWindow *self); void console_clear(ConsoleWindow *self);
void break_debugger(ConsoleWindow *self); void break_debugger(ConsoleWindow *self);
void abort_debugger(ConsoleWindow *self);
#endif #endif

View File

@ -435,12 +435,13 @@ static void stop(void) {
GB_audio_set_paused(true); GB_audio_set_paused(true);
GB_debugger_set_disabled(&gb, true); GB_debugger_set_disabled(&gb, true);
if (GB_debugger_is_stopped(&gb)) {
// [self interruptDebugInputRead];
}
gui_data.stopping = true; gui_data.stopping = true;
gui_data.running = false; gui_data.running = false;
if (GB_debugger_is_stopped(&gb)) {
abort_debugger(gui_data.console);
}
while (gui_data.stopping); while (gui_data.stopping);
GB_debugger_set_disabled(&gb, false); GB_debugger_set_disabled(&gb, false);