Fix restoration of MementoCommand<Crossfade>. Fixes #3418.
git-svn-id: svn://localhost/ardour2/branches/3.0@7771 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
42acfc365f
commit
875f0befd5
@ -91,6 +91,8 @@ public:
|
||||
|
||||
void update (const CrossfadeListProperty::ChangeRecord &);
|
||||
|
||||
boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &) const;
|
||||
|
||||
protected:
|
||||
|
||||
/* playlist "callbacks" */
|
||||
|
@ -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<Crossfade> find_crossfade (const PBD::ID &) const {
|
||||
return boost::shared_ptr<Crossfade> ();
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class Session;
|
||||
|
||||
|
@ -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<boost::shared_ptr<Playlist> >&);
|
||||
void unassigned (std::list<boost::shared_ptr<Playlist> > & list);
|
||||
void destroy_region (boost::shared_ptr<Region>);
|
||||
boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &);
|
||||
|
||||
private:
|
||||
friend class Session;
|
||||
|
@ -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<Crossfade>
|
||||
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<Crossfade> ();
|
||||
}
|
||||
|
||||
return *i;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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<Crossfade> c = playlists->find_crossfade (id);
|
||||
if (c) {
|
||||
return new MementoCommand<Crossfade> (*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<PBD::StatefulDestructible>(*registry[id], before, after);
|
||||
}
|
||||
|
@ -390,3 +390,26 @@ SessionPlaylists::XMLPlaylistFactory (Session& session, const XMLNode& node)
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<Crossfade>
|
||||
SessionPlaylists::find_crossfade (const PBD::ID& id)
|
||||
{
|
||||
Glib::Mutex::Lock lm (lock);
|
||||
|
||||
boost::shared_ptr<Crossfade> 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<Crossfade> ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user