From 02115563feabd8d0019bfda605c88552c24f0890 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 2 Oct 2006 18:09:34 +0000 Subject: [PATCH] fixes for various bugs including dangling ref to route in session, opening sessions from the NSD, closing a session leaving dangling pointers etc etc git-svn-id: svn://localhost/ardour2/trunk@938 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/actions.cc | 6 +----- gtk2_ardour/ardour_ui.cc | 8 +++----- gtk2_ardour/ardour_ui_options.cc | 2 -- gtk2_ardour/editor_actions.cc | 2 +- gtk2_ardour/editor_region_list.cc | 1 + libs/ardour/ardour/session.h | 2 +- libs/ardour/audio_diskstream.cc | 2 -- libs/ardour/audiofilesource.cc | 1 - libs/ardour/session.cc | 34 +++++++++++++++++++++++-------- 9 files changed, 33 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index 8aa8ed0cbb..885a23ffc7 100644 --- a/gtk2_ardour/actions.cc +++ b/gtk2_ardour/actions.cc @@ -294,8 +294,6 @@ ActionManager::toggle_config_state (const char* group, const char* action, bool if (tact) { bool x = (Config->*get)(); - cerr << "\ttoggle config, action = " << tact->get_active() << " config = " << x << endl; - if (x != tact->get_active()) { (Config->*set) (!x); } @@ -326,13 +324,11 @@ ActionManager::map_some_state (const char* group, const char* action, bool (Conf bool x = (Config->*get)(); - cerr << "\tmap state, action = " << tact->get_active() << " config = " << x << endl; - if (tact->get_active() != x) { tact->set_active (x); } } else { - cerr << "not a toggle\n"; + cerr << group << ':' << action << " is not a toggle\n"; } } else { cerr << group << ':' << action << " not an action\n"; diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 701c69c996..97d5c81b28 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1629,6 +1629,7 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) do { response = new_session_dialog->run (); //nsd_window ->set_cursor(Gdk::Cursor(Gdk::WATCH)); + if(response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) { quit(); return; @@ -1645,7 +1646,6 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) if (session_name.empty()) { response = Gtk::RESPONSE_NONE; - cerr << "session name is empty\n"; continue; } @@ -1660,6 +1660,8 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) } else if (response == Gtk::RESPONSE_OK) { + session_name = new_session_dialog->session_name(); + if (new_session_dialog->get_current_page() == 1) { /* XXX this is a bit of a hack.. @@ -1670,7 +1672,6 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) if (session_name.empty()) { response = Gtk::RESPONSE_NONE; - cerr << "session name is empty 2\n"; continue; } @@ -1687,11 +1688,8 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) _session_is_new = true; - session_name = new_session_dialog->session_name(); - if (session_name.empty()) { response = Gtk::RESPONSE_NONE; - cerr << "session name is empty 3\n"; continue; } diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index 7a3ebfc130..64f4dcfc85 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -747,8 +747,6 @@ ARDOUR_UI::set_meter_falloff (MeterFalloff val) void ARDOUR_UI::parameter_changed (const char* parameter_name) { - cerr << "Parameter changed : " << parameter_name << endl; - #define PARAM_IS(x) (!strcmp (parameter_name, (x))) if (PARAM_IS ("slave-source")) { diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index b36e4ff7f9..6fb8950047 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -816,7 +816,7 @@ Editor::parameter_changed (const char* parameter_name) } else if (PARAM_IS ("crossfades-visible")) { ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_crossfades_visible); } else if (PARAM_IS ("auto-xfade")) { - ActionManager::map_some_state ("Editor", "toggle-auto-xfade", &Configuration::get_auto_xfade); + ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade); } else if (PARAM_IS ("edit-mode")) { edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode())); } diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index 31215e47a6..397c401e0c 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -235,6 +235,7 @@ Editor::redisplay_regions () for (list >::iterator r = tmp_audio_region_list.begin(); r != tmp_audio_region_list.end(); ++r) { add_audio_region_to_region_display (*r); } + tmp_audio_region_list.clear(); region_list_display.set_model (region_list_model); } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f6d5e9cc8d..79fd442995 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1419,7 +1419,7 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible bool currently_soloing; void route_mute_changed (void *src); - void route_solo_changed (void *src, boost::shared_ptr); + void route_solo_changed (void *src, boost::weak_ptr); void catch_up_on_solo (); void update_route_solo_state (); void modify_solo_mute (bool, bool); diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 71d16583e0..89bffc89e3 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -1967,8 +1967,6 @@ AudioDiskstream::reset_write_sources (bool mark_write_complete, bool force) ChannelList::iterator chan; uint32_t n; - cerr << _name << " RWS\n"; - if (!recordable()) { return; } diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index dfc07de787..9564fff53b 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -101,7 +101,6 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node) AudioFileSource::~AudioFileSource () { if (removable()) { - cerr << "Removing file " << _path << " because its removable\n"; unlink (_path.c_str()); unlink (peakpath.c_str()); } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 057774b49c..bf5f5fcb78 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1825,7 +1825,10 @@ Session::add_routes (RouteList& new_routes, bool save) } for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) { - (*x)->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), (*x))); + + boost::weak_ptr wpr (*x); + + (*x)->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), wpr)); (*x)->mute_changed.connect (mem_fun (*this, &Session::route_mute_changed)); (*x)->output_changed.connect (mem_fun (*this, &Session::set_worst_io_latencies_x)); (*x)->redirects_changed.connect (mem_fun (*this, &Session::update_latency_compensation_proxy)); @@ -1883,11 +1886,11 @@ Session::remove_route (shared_ptr route) */ if (route == _master_out) { - _master_out = shared_ptr ((Route*) 0); + _master_out = shared_ptr (); } if (route == _control_out) { - _control_out = shared_ptr ((Route*) 0); + _control_out = shared_ptr (); /* cancel control outs for all routes */ @@ -1925,13 +1928,21 @@ Session::remove_route (shared_ptr route) update_latency_compensation (false, false); set_dirty(); - /* XXX should we disconnect from the Route's signals ? */ + /* get rid of it from the dead wood collection in the route list manager */ - save_state (_current_snapshot_name); + /* XXX i think this is unsafe as it currently stands, but i am not sure. (pd, october 2nd, 2006) */ + + routes.flush (); /* try to cause everyone to drop their references */ route->drop_references (); + + /* save the new state of the world */ + + if (save_state (_current_snapshot_name)) { + save_history (_current_snapshot_name); + } } void @@ -1941,7 +1952,7 @@ Session::route_mute_changed (void* src) } void -Session::route_solo_changed (void* src, shared_ptr route) +Session::route_solo_changed (void* src, boost::weak_ptr wpr) { if (solo_update_disabled) { // We know already @@ -1949,8 +1960,15 @@ Session::route_solo_changed (void* src, shared_ptr route) } bool is_track; - - is_track = (dynamic_cast(route.get()) != 0); + boost::shared_ptr route = wpr.lock (); + + if (!route) { + /* should not happen */ + error << string_compose (_("programming error: %1"), X_("invalid route weak ptr passed to route_solo_changed")) << endmsg; + return; + } + + is_track = (boost::dynamic_pointer_cast(route) != 0); shared_ptr r = routes.reader ();