From 9c0beeb7591302747eee6e28c448314313f8d54a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 22 Sep 2019 21:45:30 -0600 Subject: [PATCH] fix problem with ArdourDialog::on_delete_event() not being called when appropriate during app startup The dialog is run using gtk_dialog_run() which uses on_response() to deal with delete/close events unlike a regular top level event loop. Probably even better would be run run the dialog from the top level event loop, but this is a bit complex --- gtk2_ardour/engine_dialog.cc | 21 +++++++++++++++++++-- gtk2_ardour/engine_dialog.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 107e5bbf24..5e3ed3ee38 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -3101,13 +3101,30 @@ EngineControl::use_latency_button_clicked () } } +void +EngineControl::on_response (int rid) +{ + /* this gets called if this Dialog is running under gtk_dialog_run() + rather than in the toplevel loop. This happens during program + startup. + */ + + if (rid == RESPONSE_DELETE_EVENT) { + on_delete_event ((GdkEventAny*) 0); + return; + } + + ArdourDialog::on_response (rid); +} + bool EngineControl::on_delete_event (GdkEventAny* ev) { - if (notebook.get_current_page() == 2) { - /* currently on latency tab - be sure to clean up */ + if (lm_running || notebook.get_current_page() == 2) { + /* currently measuring latency - be sure to clean up */ end_latency_detection (); } + return ArdourDialog::on_delete_event (ev); } diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index a31adc7baf..bd6bf9acde 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -353,6 +353,7 @@ private: void on_switch_page (GtkNotebookPage*, guint page_num); bool on_delete_event (GdkEventAny*); + void on_response (int); void engine_running (); void engine_stopped ();