From: Carl Hetherington Date: Tue, 14 Sep 2010 00:41:53 +0000 (+0000) Subject: Fix restoration of MementoCommand. Fixes #3418. X-Git-Tag: 3.0-alpha5~1493 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=875f0befd5fb52678d25544fcbcb6e6b55a2c483 Fix restoration of MementoCommand. Fixes #3418. git-svn-id: svn://localhost/ardour2/branches/3.0@7771 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index 39a19d8ed1..edf5008283 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -91,6 +91,8 @@ public: void update (const CrossfadeListProperty::ChangeRecord &); + boost::shared_ptr find_crossfade (const PBD::ID &) const; + protected: /* playlist "callbacks" */ diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index feea056ac3..67638cf15e 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -50,6 +50,7 @@ namespace ARDOUR { class Session; class Region; class Playlist; +class Crossfade; namespace Properties { /* fake the type, since regions are handled by SequenceProperty which doesn't @@ -210,6 +211,10 @@ public: void set_explicit_relayering (bool e); + virtual boost::shared_ptr find_crossfade (const PBD::ID &) const { + return boost::shared_ptr (); + } + protected: friend class Session; diff --git a/libs/ardour/ardour/session_playlists.h b/libs/ardour/ardour/session_playlists.h index 1c83a312a5..4ca67bdee8 100644 --- a/libs/ardour/ardour/session_playlists.h +++ b/libs/ardour/ardour/session_playlists.h @@ -41,6 +41,7 @@ class Playlist; class Region; class Source; class Session; +class Crossfade; class SessionPlaylists : public PBD::ScopedConnectionList { @@ -54,6 +55,7 @@ public: void get (std::vector >&); void unassigned (std::list > & list); void destroy_region (boost::shared_ptr); + boost::shared_ptr find_crossfade (const PBD::ID &); private: friend class Session; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 5019935d5d..9c3bce4196 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -875,3 +875,18 @@ AudioPlaylist::update (const CrossfadeListProperty::ChangeRecord& change) /* don't remove crossfades here; they will be dealt with by the dependency code */ } + +boost::shared_ptr +AudioPlaylist::find_crossfade (const PBD::ID& id) const +{ + Crossfades::const_iterator i = _crossfades.begin (); + while (i != _crossfades.end() && (*i)->id() != id) { + ++i; + } + + if (i == _crossfades.end()) { + return boost::shared_ptr (); + } + + return *i; +} diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index 67ccea9371..6b0c0a9560 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -717,6 +717,8 @@ Crossfade::get_state () char buf[64]; LocaleGuard lg (X_("POSIX")); + id().print (buf, sizeof (buf)); + node->add_property ("id", buf); _out->id().print (buf, sizeof (buf)); node->add_property ("out", buf); _in->id().print (buf, sizeof (buf)); @@ -774,6 +776,10 @@ Crossfade::set_state (const XMLNode& node, int /*version*/) PropertyChange what_changed; framepos_t val; + if ((prop = node.property (X_("id")))) { + _id = prop->value(); + } + if ((prop = node.property ("position")) != 0) { sscanf (prop->value().c_str(), "%" PRId64, &val); if (val != _position) { diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 8d3ce793bc..17c7d559d4 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -34,6 +34,7 @@ #include "ardour/session_playlists.h" #include "ardour/region_factory.h" #include "ardour/midi_automation_list_binder.h" +#include "ardour/crossfade.h" #include "pbd/error.h" #include "pbd/id.h" #include "pbd/statefuldestructible.h" @@ -140,7 +141,15 @@ Session::memento_command_factory(XMLNode *n) } cerr << "Alist not found\n"; - + + } else if (obj_T == "ARDOUR::Crossfade") { + boost::shared_ptr c = playlists->find_crossfade (id); + if (c) { + return new MementoCommand (*c.get(), before, after); + } else { + error << string_compose (X_("Crossfade %1 not found in session"), id) << endmsg; + } + } else if (registry.count(id)) { // For Editor and AutomationLine which are off-limits herea return new MementoCommand(*registry[id], before, after); } diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index 38c6744d06..b54faba97e 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -390,3 +390,26 @@ SessionPlaylists::XMLPlaylistFactory (Session& session, const XMLNode& node) } } +boost::shared_ptr +SessionPlaylists::find_crossfade (const PBD::ID& id) +{ + Glib::Mutex::Lock lm (lock); + + boost::shared_ptr c; + + for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) { + c = (*i)->find_crossfade (id); + if (c) { + return c; + } + } + + for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { + c = (*i)->find_crossfade (id); + if (c) { + return c; + } + } + + return boost::shared_ptr (); +}