From fbb9576d4047c03276cc2e1b750465c3b0371c6c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 21 Oct 2006 05:12:11 +0000 Subject: various fixes related to lifetime management and xfades in particular. lots and lots and lots of debugging output, but sampo can test startup now. shutdown will still crash, but for a new reason. git-svn-id: svn://localhost/ardour2/trunk@998 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 20 +++++++++++++------- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_ops.cc | 2 +- libs/ardour/ardour/playlist.h | 2 +- libs/ardour/audio_playlist.cc | 35 ++++++++++++++++++++++++++++++++--- libs/ardour/audioregion.cc | 1 + libs/ardour/crossfade.cc | 2 ++ libs/ardour/playlist.cc | 16 ++++++++-------- libs/ardour/region.cc | 2 -- libs/ardour/session.cc | 3 ++- libs/pbd/pbd/memento_command.h | 3 +++ 11 files changed, 64 insertions(+), 24 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 99e1f5bb1e..eb3c3ac212 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1691,7 +1691,7 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr become selected. */ - region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region)); + region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr(region))); items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region))); items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top))); @@ -3198,9 +3198,15 @@ Editor::set_selected_regionview_from_region_list (boost::shared_ptr regi } bool -Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr r) +Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::weak_ptr weak_r) { RegionView* rv; + boost::shared_ptr r (weak_r.lock()); + + if (!r) { + return true; + } + boost::shared_ptr ar; if ((ar = boost::dynamic_pointer_cast (r)) == 0) { @@ -3524,15 +3530,15 @@ Editor::zoom_focus_selection_done () string choice = zoom_focus_selector.get_active_text(); ZoomFocus focus_type = ZoomFocusLeft; - if (choice == _("Focus Left")) { + if (choice == _("Left")) { focus_type = ZoomFocusLeft; - } else if (choice == _("Focus Right")) { + } else if (choice == _("Right")) { focus_type = ZoomFocusRight; - } else if (choice == _("Focus Center")) { + } else if (choice == _("Center")) { focus_type = ZoomFocusCenter; - } else if (choice == _("Focus Playhead")) { + } else if (choice == _("Playhead")) { focus_type = ZoomFocusPlayhead; - } else if (choice == _("Focus Edit Cursor")) { + } else if (choice == _("Edit Cursor")) { focus_type = ZoomFocusEdit; } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index c83a0da3a0..eb8f050d91 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -441,7 +441,7 @@ class Editor : public PublicEditor bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false); void set_selected_regionview_from_region_list (boost::shared_ptr region, Selection::Operation op = Selection::Set); - bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::shared_ptr); + bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr); void collect_new_region_view (RegionView *); Gtk::Menu track_context_menu; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 280804c94f..c7a10df5a0 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -3340,7 +3340,7 @@ Editor::normalize_region () continue; XMLNode &before = arv->region()->get_state(); arv->audio_region()->normalize_to (0.0f); - session->add_command (new MementoCommand(*(arv->region().get()), &before, &arv->region()->get_state())); + // session->add_command (new MementoCommand(*(arv->region().get()), &before, &arv->region()->get_state())); } commit_reversible_command (); diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 2d19f661c4..9cc3f86f0b 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -178,7 +178,7 @@ class Playlist : public PBD::StatefulDestructible { bool pending_length; bool save_on_thaw; string last_save_reason; - bool in_set_state; + uint32_t in_set_state; bool _hidden; bool _splicing; bool _nudging; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index be8680882f..cce6e188f8 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -42,9 +42,9 @@ using namespace PBD; AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden) : Playlist (session, node, hidden) { - in_set_state = true; + in_set_state++; set_state (node); - in_set_state = false; + in_set_state--; if (!hidden) { PlaylistCreated (this); /* EMIT SIGNAL */ @@ -120,10 +120,24 @@ AudioPlaylist::~AudioPlaylist () /* drop connections to signals */ notify_callbacks (); + + + cerr << "deleting crossfades " << _crossfades.size() << endl; + + for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ) { + Crossfades::iterator tmp; + + tmp = x; + ++tmp; - for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ++x) { delete *x; + + cerr << _crossfades.size() << " to go\n"; + + x = tmp; } + + cerr << "done\n"; } struct RegionSortByLayer { @@ -226,6 +240,10 @@ AudioPlaylist::remove_dependents (boost::shared_ptr region) { Crossfades::iterator i, tmp; boost::shared_ptr r = boost::dynamic_pointer_cast (region); + + if (in_set_state) { + return; + } if (r == 0) { fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist") @@ -354,6 +372,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) return; } + cerr << "Check dependents of " << r->name() << endl; + if ((region = boost::dynamic_pointer_cast (r)) == 0) { fatal << _("programming error: non-audio Region tested for overlap in audio playlist") << endmsg; @@ -441,7 +461,10 @@ AudioPlaylist::add_crossfade (Crossfade& xfade) { Crossfades::iterator ci; + cerr << "adding xfade involving " << xfade.in()->name() << " and " << xfade.out()->name() << endl; + for (ci = _crossfades.begin(); ci != _crossfades.end(); ++ci) { + cerr << "\tcompare to " << (*ci)->in()->name() << " and " << (*ci)->out()->name() << endl; if (*(*ci) == xfade) { // Crossfade::operator==() break; } @@ -488,6 +511,9 @@ AudioPlaylist::set_state (const XMLNode& node) XMLNodeList nlist; XMLNodeConstIterator niter; + in_set_state++; + freeze (); + Playlist::set_state (node); nlist = node.children(); @@ -516,6 +542,9 @@ AudioPlaylist::set_state (const XMLNode& node) } } + thaw (); + in_set_state++; + return 0; } diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index d2cf279d3e..2f2c67ec50 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -306,6 +306,7 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node) AudioRegion::~AudioRegion () { + cerr << "====== " << _name << " DESTRUCTOR @ " << this << endl; notify_callbacks (); GoingAway (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index 50e3ff2905..739ea1cc0e 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -197,7 +197,9 @@ Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr newi Crossfade::~Crossfade () { + cerr << "Deleting xfade @ " << this << endl; Invalidated (this); + cerr << "invalidation signal sent\n"; } void diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index ef5fe276bb..87eed692b6 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -99,19 +99,19 @@ Playlist::Playlist (const Playlist& other, string namestr, bool hide) RegionList tmp; other.copy_regions (tmp); - in_set_state = true; + in_set_state++; for (list >::iterator x = tmp.begin(); x != tmp.end(); ++x) { add_region_internal( (*x), (*x)->position() ); } - in_set_state = false; + in_set_state--; _splicing = other._splicing; _nudging = other._nudging; _edit_mode = other._edit_mode; - in_set_state = false; + in_set_state = 0; in_flush = false; in_partition = false; subcnt = 0; @@ -230,7 +230,7 @@ Playlist::init (bool hide) _hidden = hide; _splicing = false; _nudging = false; - in_set_state = false; + in_set_state = 0; _edit_mode = Config->get_edit_mode(); in_flush = false; in_partition = false; @@ -1321,10 +1321,10 @@ Playlist::set_state (const XMLNode& node) boost::shared_ptr region; string region_name; - in_set_state = true; + in_set_state++; if (node.name() != "Playlist") { - in_set_state = false; + in_set_state--; return -1; } @@ -1394,10 +1394,10 @@ Playlist::set_state (const XMLNode& node) notify_modified (); - in_set_state = false; - thaw (); + in_set_state--; + return 0; } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 6e6af0ee11..d49ed933c9 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -144,8 +144,6 @@ Region::Region (const XMLNode& node) Region::~Region () { - // cerr << "====== " << _name << " DESTRUCTOR\n"; - // stacktrace (cerr); /* derived classes must call notify_callbacks() and then emit GoingAway */ } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index e4ff1941e0..66cb1f89fa 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -469,8 +469,9 @@ Session::~Session () tmp = i; ++tmp; - cerr << "dropping refs on an audio region (" << i->second->name() << ") with UC = " << i->second.use_count() << endl; + cerr << "dropping refs on an audio region (" << i->second->name() << " @ " << i->second << ") with UC = " << i->second.use_count() << endl; i->second->drop_references (); + cerr << "AFTER: UC = " << i->second.use_count() << endl; i = tmp; } diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index 715e9d33e3..d42972d546 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -26,6 +26,7 @@ using std::cerr; using std::endl; #include +#include #include #include #include @@ -36,6 +37,7 @@ using std::endl; */ static void object_death (Command* mc) { + cerr << "\n\n\n---> OBJECT DEATH FIRED FOR " << mc << endl; delete mc; } @@ -53,6 +55,7 @@ class MementoCommand : public Command XMLNode *after ) : obj(object), before(before), after(after) { + cerr << "MC @ " << this << " is a " << typeid (obj_T).name() << endl; obj.GoingAway.connect (sigc::bind (sigc::ptr_fun (object_death), static_cast(this))); } -- cgit v1.2.3