From 19fc6e831be3df02bc1185ad2a4e194733ba1049 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 Nov 2024 17:23:42 +0100 Subject: [PATCH] Fix missing calls to SessionHandlePtr::session_going_away() Explicit calls to set_session(0) will disconnect the callback to session_going_away(). So don't do that. --- gtk2_ardour/application_bar.cc | 1 + gtk2_ardour/ardour_ui_dialogs.cc | 3 --- gtk2_ardour/audio_region_properties_box.cc | 4 ++++ gtk2_ardour/audio_trigger_properties_box.cc | 4 ++++ gtk2_ardour/big_transport_window.h | 5 ++++- gtk2_ardour/cuebox_ui.h | 7 ++++++- gtk2_ardour/dsp_stats_window.cc | 5 ++++- gtk2_ardour/editor.cc | 4 +--- gtk2_ardour/editor_locations.cc | 4 +++- gtk2_ardour/export_format_dialog.cc | 5 +++-- gtk2_ardour/io_plugin_window.cc | 5 +++-- gtk2_ardour/location_ui.cc | 19 ++++++++----------- gtk2_ardour/midi_clip_editor.cc | 4 +++- gtk2_ardour/mixer_ui.cc | 14 +++++++------- gtk2_ardour/monitor_section.cc | 3 ++- gtk2_ardour/option_editor.cc | 4 +++- gtk2_ardour/plugin_pin_dialog.cc | 3 +++ gtk2_ardour/port_matrix.cc | 1 + gtk2_ardour/pt_import_selector.cc | 2 +- gtk2_ardour/rc_option_editor.cc | 3 +++ gtk2_ardour/recorder_ui.cc | 14 +++++++------- gtk2_ardour/selection_properties_box.cc | 4 ++++ gtk2_ardour/sfdb_ui.cc | 7 +++---- gtk2_ardour/shuttle_control.cc | 2 +- gtk2_ardour/time_info_box.cc | 14 ++++++++------ gtk2_ardour/transport_masters_dialog.cc | 4 +++- gtk2_ardour/trigger_page.cc | 10 +++++----- gtk2_ardour/window_manager.cc | 3 +++ gtk2_ardour/window_manager.h | 6 ++++++ 29 files changed, 104 insertions(+), 60 deletions(-) diff --git a/gtk2_ardour/application_bar.cc b/gtk2_ardour/application_bar.cc index 76678e5e51..ce5e223c91 100644 --- a/gtk2_ardour/application_bar.cc +++ b/gtk2_ardour/application_bar.cc @@ -784,6 +784,7 @@ ApplicationBar::set_session (Session *s) if (_basic_ui) { delete _basic_ui; + _basic_ui = 0; } map_transport_state (); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index eeaef4d866..fbdcbf48fb 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -125,7 +125,6 @@ ARDOUR_UI::set_session (Session *s) update_sample_rate (); if (!_session) { - WM::Manager::instance().set_session (s); /* Session option editor cannot exist across change-of-session */ session_option_editor.drop_window (); /* Ditto for AddVideoDialog */ @@ -306,8 +305,6 @@ ARDOUR_UI::unload_session (bool hide_stuff, bool force_unload) ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false); - WM::Manager::instance().set_session ((ARDOUR::Session*) 0); - if (ARDOUR_UI::instance()->video_timeline) { ARDOUR_UI::instance()->video_timeline->close_session(); } diff --git a/gtk2_ardour/audio_region_properties_box.cc b/gtk2_ardour/audio_region_properties_box.cc index 377c0e2f56..2c84c57ab8 100644 --- a/gtk2_ardour/audio_region_properties_box.cc +++ b/gtk2_ardour/audio_region_properties_box.cc @@ -112,6 +112,10 @@ RegionPropertiesBox::set_session (Session* s) { SessionHandlePtr::set_session (s); + if (s) { + return; + } + length_clock.set_session (s); start_clock.set_session (s); } diff --git a/gtk2_ardour/audio_trigger_properties_box.cc b/gtk2_ardour/audio_trigger_properties_box.cc index 8f15390316..31c9322ca4 100644 --- a/gtk2_ardour/audio_trigger_properties_box.cc +++ b/gtk2_ardour/audio_trigger_properties_box.cc @@ -197,6 +197,10 @@ AudioTriggerPropertiesBox::set_session (Session* s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } + _length_clock.set_session (s); _start_clock.set_session (s); } diff --git a/gtk2_ardour/big_transport_window.h b/gtk2_ardour/big_transport_window.h index 4369578ded..e70cb01182 100644 --- a/gtk2_ardour/big_transport_window.h +++ b/gtk2_ardour/big_transport_window.h @@ -32,7 +32,10 @@ public: BigTransportWindow (); void set_session (ARDOUR::Session *s) { - transport_ctrl.set_session (s); + ArdourWindow::set_session (s); + if (s) { + transport_ctrl.set_session (s); + } } protected: diff --git a/gtk2_ardour/cuebox_ui.h b/gtk2_ardour/cuebox_ui.h index be384c244a..984c835cca 100644 --- a/gtk2_ardour/cuebox_ui.h +++ b/gtk2_ardour/cuebox_ui.h @@ -108,7 +108,12 @@ class CueBoxWidget : public FittedCanvasWidget, public ARDOUR::SessionHandlePtr public: CueBoxWidget (float w, float h); - void set_session (ARDOUR::Session* s) {ui->set_session(s); SessionHandlePtr::set_session(s);} + void set_session (ARDOUR::Session* s) { + SessionHandlePtr::set_session(s); + if (s) { + ui->set_session(s); + } + } void on_map (); void on_unmap (); diff --git a/gtk2_ardour/dsp_stats_window.cc b/gtk2_ardour/dsp_stats_window.cc index 81cdd82310..70d0390ca2 100644 --- a/gtk2_ardour/dsp_stats_window.cc +++ b/gtk2_ardour/dsp_stats_window.cc @@ -41,7 +41,10 @@ DspStatisticsWindow::~DspStatisticsWindow () void DspStatisticsWindow::set_session (Session* s) { - ui->set_session (s); + ArdourWindow::set_session (s); + if (s) { + ui->set_session (s); + } } void diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ed9f70fd52..fd99fe9c96 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1193,7 +1193,6 @@ void Editor::set_session (Session *t) { SessionHandlePtr::set_session (t); - _trigger_clip_picker.set_session (_session); section_marker_bar->clear (true); @@ -1206,6 +1205,7 @@ Editor::set_session (Session *t) * before the visible state has been loaded from instant.xml */ _leftmost_sample = session_gui_extents().first.samples(); + _trigger_clip_picker.set_session (_session); _application_bar.set_session (_session); nudge_clock->set_session (_session); _summary->set_session (_session); @@ -5508,8 +5508,6 @@ Editor::session_going_away () } track_views.clear (); - nudge_clock->set_session (0); - /* clear tempo/meter rulers */ remove_metric_marks (); clear_marker_display (); diff --git a/gtk2_ardour/editor_locations.cc b/gtk2_ardour/editor_locations.cc index 6eb7cf721f..cabd7743ed 100644 --- a/gtk2_ardour/editor_locations.cc +++ b/gtk2_ardour/editor_locations.cc @@ -37,7 +37,9 @@ void EditorLocations::set_session (ARDOUR::Session* s) { SessionHandlePtr::set_session (s); - _locations->set_session (s); + if (s) { + _locations->set_session (s); + } } Widget& diff --git a/gtk2_ardour/export_format_dialog.cc b/gtk2_ardour/export_format_dialog.cc index c62ce32233..7426540a46 100644 --- a/gtk2_ardour/export_format_dialog.cc +++ b/gtk2_ardour/export_format_dialog.cc @@ -354,13 +354,14 @@ void ExportFormatDialog::set_session (ARDOUR::Session* s) { SessionHandlePtr::set_session (s); - silence_start_clock.set_session (s); - silence_end_clock.set_session (s); if (!_session) { return; } + silence_start_clock.set_session (s); + silence_end_clock.set_session (s); + update_clock (silence_start_clock, silence_start); update_clock (silence_end_clock, silence_end); diff --git a/gtk2_ardour/io_plugin_window.cc b/gtk2_ardour/io_plugin_window.cc index 4f4fd53ec4..62c18d1988 100644 --- a/gtk2_ardour/io_plugin_window.cc +++ b/gtk2_ardour/io_plugin_window.cc @@ -93,12 +93,13 @@ void IOPluginWindow::set_session (Session* s) { ArdourWindow::set_session (s); - _box_pre.set_session (s); - _box_post.set_session (s); if (!_session) { return; } + + _box_pre.set_session (s); + _box_post.set_session (s); refill (); _session->IOPluginsChanged.connect (_session_connections, invalidator (*this), std::bind (&IOPluginWindow::refill, this), gui_context ()); } diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index e940754a97..480dca32c6 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -214,6 +214,7 @@ LocationEditRow::set_session (Session *sess) SessionHandlePtr::set_session (sess); if (!_session) { + set_location (0); return; } @@ -1130,13 +1131,13 @@ LocationUI::set_session(ARDOUR::Session* s) Location::start_changed.connect (_session_connections, invalidator (*this), std::bind (&LocationUI::start_changed, this, _1), gui_context()); _clock_group->set_clock_mode (clock_mode_from_session_instant_xml ()); + + loop_edit_row.set_session (s); + punch_edit_row.set_session (s); } else { _mode_set = false; } - loop_edit_row.set_session (s); - punch_edit_row.set_session (s); - refresh_location_list (); } @@ -1152,12 +1153,6 @@ LocationUI::session_going_away() loc_children.clear(); range_children.clear(); - loop_edit_row.set_session (0); - loop_edit_row.set_location (0); - - punch_edit_row.set_session (0); - punch_edit_row.set_location (0); - _mode_set = false; SessionHandlePtr::session_going_away (); @@ -1240,8 +1235,10 @@ void LocationUIWindow::set_session (Session *s) { ArdourWindow::set_session (s); - _ui.set_session (s); - _ui.show_all (); + if (s) { + _ui.set_session (s); + _ui.show_all (); + } } void diff --git a/gtk2_ardour/midi_clip_editor.cc b/gtk2_ardour/midi_clip_editor.cc index b2ee93dd1f..02575f8ff6 100644 --- a/gtk2_ardour/midi_clip_editor.cc +++ b/gtk2_ardour/midi_clip_editor.cc @@ -75,7 +75,9 @@ void MidiClipEditorBox::set_session (Session* s) { SessionHandlePtr::set_session (s); - editor->set_session (s); + if (s) { + editor->set_session (s); + } } void diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index ada04a5264..dd581dbfb9 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -1278,16 +1278,16 @@ void Mixer_UI::set_session (Session* sess) { SessionHandlePtr::set_session (sess); - _monitor_section.set_session (sess); - if (_plugin_selector) { - _plugin_selector->set_session (_session); + if (sess) { + _monitor_section.set_session (sess); + _group_tabs->set_session (sess); + _application_bar.set_session (_session); + if (_plugin_selector) { + _plugin_selector->set_session (_session); + } } - _group_tabs->set_session (sess); - - _application_bar.set_session (_session); - update_scene_buttons(); RefPtr surround_action = ActionManager::get_toggle_action (X_("Mixer"), "ToggleSurroundMaster"); diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc index ff4f253166..40831a3fe4 100644 --- a/gtk2_ardour/monitor_section.cc +++ b/gtk2_ardour/monitor_section.cc @@ -584,12 +584,13 @@ void MonitorSection::set_session (Session* s) { RouteUI::set_session (s); - insert_box->set_session (_session); Glib::RefPtr global_monitor_actions = ActionManager::get_action_group (X_("Monitor Section")); if (_session) { + insert_box->set_session (_session); + /* These are not actually dependent on the Session, but they * need to be set after construction, not during, and * this is as good a place as any. diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 89b1e55c86..35eba57923 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -730,7 +730,9 @@ void ClockOption::set_session (Session* s) { _session = s; - _clock.set_session (s); + if (s) { + _clock.set_session (s); + } } /*--------------------------*/ diff --git a/gtk2_ardour/plugin_pin_dialog.cc b/gtk2_ardour/plugin_pin_dialog.cc index 9ed7038cb8..0db9606676 100644 --- a/gtk2_ardour/plugin_pin_dialog.cc +++ b/gtk2_ardour/plugin_pin_dialog.cc @@ -2162,6 +2162,9 @@ void PluginPinDialog::set_session (ARDOUR::Session *s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } for (PluginPinWidgetList::iterator i = ppw.begin(); i != ppw.end(); ++i) { (*i)->set_session (s); } diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 3cbd583338..e0949d14ba 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -928,6 +928,7 @@ PortMatrix::notebook_page_selected (GtkNotebookPage *, guint) void PortMatrix::session_going_away () { + SessionHandlePtr::session_going_away (); _session = 0; } diff --git a/gtk2_ardour/pt_import_selector.cc b/gtk2_ardour/pt_import_selector.cc index 23f7411d13..c75010d41b 100644 --- a/gtk2_ardour/pt_import_selector.cc +++ b/gtk2_ardour/pt_import_selector.cc @@ -147,6 +147,6 @@ PTImportSelector::update_ptf() void PTImportSelector::set_session (Session* s) { - ArdourDialog::set_session (s); + ArdourDialog::set_session (s); _session_rate = s->sample_rate (); } diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index bf876031ea..1671f1f11c 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -5113,6 +5113,9 @@ void RCOptionEditor::set_session (Session *s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } _transport_masters_widget.set_session (s); } diff --git a/gtk2_ardour/recorder_ui.cc b/gtk2_ardour/recorder_ui.cc index 680a8515a7..1ad597958f 100644 --- a/gtk2_ardour/recorder_ui.cc +++ b/gtk2_ardour/recorder_ui.cc @@ -396,13 +396,6 @@ RecorderUI::set_session (Session* s) { SessionHandlePtr::set_session (s); - _ruler.set_session (s); - _duration_info_box.set_session (s); - _xrun_info_box.set_session (s); - _remain_info_box.set_session (s); - _application_bar.set_session (s); - _rec_group_tabs->set_session (s); - update_sensitivity (); if (!_session) { @@ -411,6 +404,13 @@ RecorderUI::set_session (Session* s) return; } + _ruler.set_session (s); + _duration_info_box.set_session (s); + _xrun_info_box.set_session (s); + _remain_info_box.set_session (s); + _application_bar.set_session (s); + _rec_group_tabs->set_session (s); + XMLNode* node = ARDOUR_UI::instance()->recorder_settings(); set_state (*node, Stateful::loading_state_version); diff --git a/gtk2_ardour/selection_properties_box.cc b/gtk2_ardour/selection_properties_box.cc index 4dde6d43a8..ee0be23bcc 100644 --- a/gtk2_ardour/selection_properties_box.cc +++ b/gtk2_ardour/selection_properties_box.cc @@ -133,6 +133,10 @@ SelectionPropertiesBox::set_session (Session* s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } + _time_info_box->set_session(s); #if SELECTION_PROPERTIES_BOX_TODO diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index c2db051402..a0ad3f0560 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -279,14 +279,13 @@ SoundFileBox::set_session(Session* s) { SessionHandlePtr::set_session (s); - length_clock.set_session (s); - timecode_clock.set_session (s); - if (!_session) { play_btn.set_sensitive (false); stop_btn.set_sensitive (false); auditioner_connections.drop_connections(); } else { + length_clock.set_session (s); + timecode_clock.set_session (s); auditioner_connections.drop_connections(); if (_session->the_auditioner()) { _session->AuditionActive.connect(auditioner_connections, invalidator (*this), std::bind (&SoundFileBox::audition_active, this, _1), gui_context()); @@ -989,9 +988,9 @@ void SoundFileBrowser::set_session (Session* s) { ArdourWindow::set_session (s); - preview.set_session (s); if (_session) { + preview.set_session (s); add_gain_meter (); } else { remove_gain_meter (); diff --git a/gtk2_ardour/shuttle_control.cc b/gtk2_ardour/shuttle_control.cc index 049bbd344d..51a1ed7c53 100644 --- a/gtk2_ardour/shuttle_control.cc +++ b/gtk2_ardour/shuttle_control.cc @@ -272,9 +272,9 @@ void ShuttleControl::set_session (Session* s) { SessionHandlePtr::set_session (s); - _vari_dialog.set_session (_session); if (_session) { + _vari_dialog.set_session (_session); _session->add_controllable (_controllable); _info_button.set_session (s); _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ShuttleControl::parameter_changed, this, _1), gui_context()); diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index 694b19a5c4..9cb1f6e87d 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -206,18 +206,20 @@ TimeInfoBox::set_session (Session* s) { SessionHandlePtr::set_session (s); - selection_start->set_session (s); - selection_end->set_session (s); - selection_length->set_session (s); + if (s) { + selection_start->set_session (s); + selection_end->set_session (s); + selection_length->set_session (s); + } if (!with_punch_clock) { return; } - punch_start->set_session (s); - punch_end->set_session (s); - if (s) { + punch_start->set_session (s); + punch_end->set_session (s); + Location* punch = s->locations()->auto_punch_location (); if (punch) { diff --git a/gtk2_ardour/transport_masters_dialog.cc b/gtk2_ardour/transport_masters_dialog.cc index aab00368f2..c8f68d259c 100644 --- a/gtk2_ardour/transport_masters_dialog.cc +++ b/gtk2_ardour/transport_masters_dialog.cc @@ -671,7 +671,9 @@ void TransportMastersWindow::set_session (ARDOUR::Session* s) { ArdourWindow::set_session (s); - w.set_session (s); + if (s) { + w.set_session (s); + } } void diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index e90a229112..5ef25a44b1 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -302,6 +302,11 @@ TriggerPage::set_session (Session* s) { SessionHandlePtr::set_session (s); + if (!_session) { + _selection.clear (); + return; + } + _application_bar.set_session (_session); _cue_box.set_session (s); _trigger_clip_picker.set_session (s); @@ -310,11 +315,6 @@ TriggerPage::set_session (Session* s) _trigger_region_list.set_session (s); _trigger_route_list.set_session (s); - if (!_session) { - _selection.clear (); - return; - } - XMLNode* node = ARDOUR_UI::instance ()->trigger_page_settings (); set_state (*node, Stateful::loading_state_version); diff --git a/gtk2_ardour/window_manager.cc b/gtk2_ardour/window_manager.cc index 076b185d8c..1919149ba9 100644 --- a/gtk2_ardour/window_manager.cc +++ b/gtk2_ardour/window_manager.cc @@ -191,6 +191,9 @@ void Manager::set_session (ARDOUR::Session* s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } for (Windows::const_iterator i = _windows.begin(); i != _windows.end(); ++i) { (*i)->set_session(s); } diff --git a/gtk2_ardour/window_manager.h b/gtk2_ardour/window_manager.h index d6385389cf..8f2deb63c5 100644 --- a/gtk2_ardour/window_manager.h +++ b/gtk2_ardour/window_manager.h @@ -153,6 +153,9 @@ public: void set_session(ARDOUR::Session *s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } ARDOUR::SessionHandlePtr* sp = session_handle (); if (sp) { sp->set_session (s); @@ -206,6 +209,9 @@ public: void set_session(ARDOUR::Session *s) { SessionHandlePtr::set_session (s); + if (!s) { + return; + } ARDOUR::SessionHandlePtr* sp = session_handle (); if (sp) { sp->set_session (s);