Use a shared_ptr for SessionPlaylists so that it can be explicitly destroyed in ~Session to ease debugging.

git-svn-id: svn://localhost/ardour2/branches/3.0@6282 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-12-04 19:09:08 +00:00
parent 681e7baa89
commit 478fd92039
14 changed files with 47 additions and 31 deletions

View file

@ -65,6 +65,7 @@
#include "ardour/session_state_utils.h"
#include "ardour/tempo.h"
#include "ardour/utils.h"
#include "ardour/session_playlists.h"
#include "control_protocol/control_protocol.h"
@ -4026,7 +4027,7 @@ Editor::new_playlists (TimeAxisView* v)
{
begin_reversible_command (_("new playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
session->playlists.get (playlists);
session->playlists->get (playlists);
mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit);
commit_reversible_command ();
}
@ -4042,7 +4043,7 @@ Editor::copy_playlists (TimeAxisView* v)
{
begin_reversible_command (_("copy playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
session->playlists.get (playlists);
session->playlists->get (playlists);
mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit);
commit_reversible_command ();
}
@ -4057,7 +4058,7 @@ Editor::clear_playlists (TimeAxisView* v)
{
begin_reversible_command (_("clear playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
session->playlists.get (playlists);
session->playlists->get (playlists);
mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit);
commit_reversible_command ();
}

View file

@ -112,7 +112,7 @@ PlaylistSelector::show_for (RouteUI* ruix)
model->clear ();
session->playlists.foreach (this, &PlaylistSelector::add_playlist_to_map);
session->playlists->foreach (this, &PlaylistSelector::add_playlist_to_map);
this_ds = rui->get_diskstream();
@ -180,7 +180,7 @@ PlaylistSelector::show_for (RouteUI* ruix)
// Add unassigned (imported) playlists to the list
list<boost::shared_ptr<Playlist> > unassigned;
session->playlists.unassigned (unassigned);
session->playlists->unassigned (unassigned);
TreeModel::Row row;
TreeModel::Row* selected_row = 0;

View file

@ -1037,7 +1037,7 @@ RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Play
name = resolve_new_group_playlist_name(name, playlists_before_op);
}
while (_session.playlists.by_name(name)) {
while (_session.playlists->by_name(name)) {
name = Playlist::bump_name (name, _session);
}
@ -1089,7 +1089,7 @@ RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playl
name = resolve_new_group_playlist_name(name,playlists_before_op);
}
while (_session.playlists.by_name(name)) {
while (_session.playlists->by_name(name)) {
name = Playlist::bump_name (name, _session);
}
@ -1497,7 +1497,7 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
boost::shared_ptr<Diskstream> ds = get_diskstream();
RadioMenuItem::Group playlist_group;
_session.playlists.get (playlists);
_session.playlists->get (playlists);
for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
@ -1585,7 +1585,7 @@ RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
continue;
}
boost::shared_ptr<Playlist> ipl = session().playlists.by_name(playlist_name);
boost::shared_ptr<Playlist> ipl = session().playlists->by_name(playlist_name);
if (!ipl) {
// No playlist for this track for this take yet, make it
track->diskstream()->use_new_playlist();

View file

@ -57,7 +57,6 @@
#include "ardour/location.h"
#include "ardour/timecode.h"
#include "ardour/interpolation.h"
#include "ardour/session_playlists.h"
class XMLTree;
class XMLNode;
@ -114,6 +113,7 @@ class SMFSource;
class Send;
class SessionDirectory;
class SessionMetadata;
class SessionPlaylists;
class Slave;
class Source;
class TempoMap;
@ -883,7 +883,7 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu
SlaveState slave_state() const { return _slave_state; }
SessionPlaylists playlists;
boost::shared_ptr<SessionPlaylists> playlists;
protected:
friend class AudioEngine;

View file

@ -57,6 +57,7 @@
#include "ardour/session.h"
#include "ardour/source_factory.h"
#include "ardour/utils.h"
#include "ardour/session_playlists.h"
#include "i18n.h"
#include <locale.h>
@ -257,7 +258,7 @@ AudioDiskstream::find_and_use_playlist (const string& name)
{
boost::shared_ptr<AudioPlaylist> playlist;
if ((playlist = boost::dynamic_pointer_cast<AudioPlaylist> (_session.playlists.by_name (name))) == 0) {
if ((playlist = boost::dynamic_pointer_cast<AudioPlaylist> (_session.playlists->by_name (name))) == 0) {
playlist = boost::dynamic_pointer_cast<AudioPlaylist> (PlaylistFactory::create (DataType::AUDIO, _session, name));
}
@ -2303,7 +2304,7 @@ AudioDiskstream::can_become_destructive (bool& requires_bounce) const
assert (afirst);
if (_session.playlists.source_use_count (afirst->source()) > 1) {
if (_session.playlists->source_use_count (afirst->source()) > 1) {
requires_bounce = true;
return false;
}

View file

@ -30,6 +30,7 @@
#include "ardour/session.h"
#include "ardour/playlist.h"
#include "ardour/playlist_factory.h"
#include "ardour/session_playlists.h"
using namespace std;
using namespace PBD;
@ -168,7 +169,7 @@ bool
AudioPlaylistImporter::_prepare_move ()
{
// Rename
while (session.playlists.by_name (name) || !handler.check_name (name)) {
while (session.playlists->by_name (name) || !handler.check_name (name)) {
std::pair<bool, string> rename_pair = Rename (_("A playlist with this name already exists, please rename it."), name);
if (!rename_pair.first) {
return false;

View file

@ -45,6 +45,7 @@
#include "ardour/route_group_specialized.h"
#include "ardour/session.h"
#include "ardour/utils.h"
#include "ardour/session_playlists.h"
#include "i18n.h"
using namespace std;
@ -388,7 +389,7 @@ AudioTrack::set_state_part_two ()
_freeze_record.processor_info.clear ();
if ((prop = fnode->property (X_("playlist"))) != 0) {
boost::shared_ptr<Playlist> pl = _session.playlists.by_name (prop->value());
boost::shared_ptr<Playlist> pl = _session.playlists->by_name (prop->value());
if (pl) {
_freeze_record.playlist = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
} else {
@ -715,7 +716,7 @@ AudioTrack::freeze (InterThreadInfo& itt)
candidate = string_compose ("<F%2>%1", _freeze_record.playlist->name(), n);
if (_session.playlists.by_name (candidate) == 0) {
if (_session.playlists->by_name (candidate) == 0) {
new_playlist_name = candidate;
break;
}

View file

@ -53,6 +53,7 @@
#include "ardour/session.h"
#include "ardour/smf_source.h"
#include "ardour/utils.h"
#include "ardour/session_playlists.h"
#include "midi++/types.h"
@ -220,7 +221,7 @@ MidiDiskstream::find_and_use_playlist (const string& name)
{
boost::shared_ptr<MidiPlaylist> playlist;
if ((playlist = boost::dynamic_pointer_cast<MidiPlaylist> (_session.playlists.by_name (name))) == 0) {
if ((playlist = boost::dynamic_pointer_cast<MidiPlaylist> (_session.playlists->by_name (name))) == 0) {
playlist = boost::dynamic_pointer_cast<MidiPlaylist> (PlaylistFactory::create (DataType::MIDI, _session, name));
}

View file

@ -41,6 +41,7 @@
#include "ardour/processor.h"
#include "ardour/route_group_specialized.h"
#include "ardour/session.h"
#include "ardour/session_playlists.h"
#include "ardour/utils.h"
#include "i18n.h"
@ -320,7 +321,7 @@ MidiTrack::set_state_part_two ()
_freeze_record.processor_info.clear ();
if ((prop = fnode->property (X_("playlist"))) != 0) {
boost::shared_ptr<Playlist> pl = _session.playlists.by_name (prop->value());
boost::shared_ptr<Playlist> pl = _session.playlists->by_name (prop->value());
if (pl) {
_freeze_record.playlist = boost::dynamic_pointer_cast<MidiPlaylist> (pl);
} else {

View file

@ -24,6 +24,7 @@
#include "ardour/utils.h"
#include "ardour/playlist.h"
#include "ardour/named_selection.h"
#include "ardour/session_playlists.h"
#include "i18n.h"
@ -82,7 +83,7 @@ NamedSelection::NamedSelection (Session& session, const XMLNode& node)
plnode = *niter;
if ((property = plnode->property ("name")) != 0) {
if ((playlist = session.playlists.by_name (property->value())) != 0) {
if ((playlist = session.playlists->by_name (property->value())) != 0) {
playlist->use();
playlists.push_back (playlist);
} else {

View file

@ -39,6 +39,7 @@
#include "ardour/region_factory.h"
#include "ardour/playlist_factory.h"
#include "ardour/transient_detector.h"
#include "ardour/session_playlists.h"
#include "i18n.h"
@ -1967,7 +1968,7 @@ Playlist::bump_name (string name, Session &session)
do {
newname = bump_name_once (newname);
} while (session.playlists.by_name (newname)!=NULL);
} while (session.playlists->by_name (newname)!=NULL);
return newname;
}

View file

@ -152,6 +152,8 @@ Session::Session (AudioEngine &eng,
_have_rec_enabled_diskstream (false)
{
playlists.reset (new SessionPlaylists);
bool new_session;
interpolation.add_channel_to (0, 0);
@ -236,6 +238,8 @@ Session::Session (AudioEngine &eng,
_metadata (new SessionMetadata()),
_have_rec_enabled_diskstream (false)
{
playlists.reset (new SessionPlaylists);
bool new_session;
interpolation.add_channel_to (0, 0);
@ -471,6 +475,9 @@ Session::destroy ()
delete mmc;
/* not strictly necessary, but doing it here allows the shared_ptr debugging to work */
playlists.reset ();
boost_debug_list_ptrs ();
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
@ -3381,7 +3388,7 @@ Session::add_playlist (boost::shared_ptr<Playlist> playlist, bool unused)
return;
}
bool existing = playlists.add (playlist);
bool existing = playlists->add (playlist);
if (!existing) {
playlist->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_playlist), boost::weak_ptr<Playlist>(playlist)));
}
@ -3406,7 +3413,7 @@ Session::remove_playlist (boost::weak_ptr<Playlist> weak_playlist)
return;
}
playlists.remove (playlist);
playlists->remove (playlist);
set_dirty();
}
@ -3765,7 +3772,7 @@ Session::tempo_map_changed (Change)
{
clear_clicks ();
playlists.update_after_tempo_map_change ();
playlists->update_after_tempo_map_change ();
set_dirty ();
}

View file

@ -31,6 +31,7 @@
#include "ardour/audioregion.h"
#include "ardour/midi_source.h"
#include "ardour/midi_region.h"
#include "ardour/session_playlists.h"
#include "pbd/error.h"
#include "pbd/id.h"
#include "pbd/statefuldestructible.h"
@ -99,7 +100,7 @@ Session::memento_command_factory(XMLNode *n)
} else if (obj_T == typeid (TempoMap).name()) {
return new MementoCommand<TempoMap>(*_tempo_map, before, after);
} else if (obj_T == typeid (Playlist).name() || obj_T == typeid (AudioPlaylist).name() || obj_T == typeid (MidiPlaylist).name()) {
if (boost::shared_ptr<Playlist> pl = playlists.by_name(child->property("name")->value())) {
if (boost::shared_ptr<Playlist> pl = playlists->by_name(child->property("name")->value())) {
return new MementoCommand<Playlist>(*(pl.get()), before, after);
}
} else if (obj_T == typeid (Route).name() || obj_T == typeid (AudioTrack).name() || obj_T == typeid(MidiTrack).name()) {

View file

@ -1062,7 +1062,7 @@ Session::state(bool full_state)
}
}
playlists.add_state (node, full_state);
playlists->add_state (node, full_state);
child = node->add_child ("RouteGroups");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
@ -1246,13 +1246,13 @@ Session::set_state (const XMLNode& node, int version)
if ((child = find_named_node (node, "Playlists")) == 0) {
error << _("Session: XML state has no playlists section") << endmsg;
goto out;
} else if (playlists.load (*this, *child)) {
} else if (playlists->load (*this, *child)) {
goto out;
}
if ((child = find_named_node (node, "UnusedPlaylists")) == 0) {
// this is OK
} else if (playlists.load_unused (*this, *child)) {
} else if (playlists->load_unused (*this, *child)) {
goto out;
}
@ -2381,7 +2381,7 @@ Session::cleanup_sources (CleanupReport& rep)
/* step 1: consider deleting all unused playlists */
if (playlists.maybe_delete_unused (AskAboutPlaylistDeletion)) {
if (playlists->maybe_delete_unused (AskAboutPlaylistDeletion)) {
ret = 0;
goto out;
}
@ -2402,7 +2402,7 @@ Session::cleanup_sources (CleanupReport& rep)
capture files.
*/
if (!playlists.source_use_count(i->second) && i->second->length(i->second->timeline_position()) > 0) {
if (!playlists->source_use_count(i->second) && i->second->length(i->second->timeline_position()) > 0) {
dead_sources.push_back (i->second);
i->second->GoingAway();
}
@ -2968,9 +2968,9 @@ Session::config_changed (std::string p, bool ours)
} else if (p == "edit-mode") {
Glib::Mutex::Lock lm (playlists.lock);
Glib::Mutex::Lock lm (playlists->lock);
for (SessionPlaylists::List::iterator i = playlists.playlists.begin(); i != playlists.playlists.end(); ++i) {
for (SessionPlaylists::List::iterator i = playlists->playlists.begin(); i != playlists->playlists.end(); ++i) {
(*i)->set_edit_mode (Config->get_edit_mode ());
}