summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_ops.cc10
-rw-r--r--libs/ardour/ardour/pi_controller.h4
-rw-r--r--libs/ardour/ardour/session_object.h2
-rw-r--r--libs/ardour/audio_diskstream.cc6
-rw-r--r--libs/ardour/crossfade.cc4
-rw-r--r--libs/ardour/io.cc8
-rw-r--r--libs/ardour/midi_diskstream.cc2
-rw-r--r--libs/ardour/midi_region.cc14
-rw-r--r--libs/ardour/midi_source.cc2
-rw-r--r--libs/ardour/mtc_slave.cc2
-rw-r--r--libs/ardour/pi_controller.cc8
-rw-r--r--libs/ardour/region.cc8
-rw-r--r--libs/ardour/route.cc1
-rw-r--r--libs/ardour/session_command.cc2
-rw-r--r--libs/ardour/sndfilesource.cc4
-rw-r--r--libs/pbd/pbd/stateful.h16
-rw-r--r--libs/pbd/pbd/stateful_diff_command.h13
-rw-r--r--libs/pbd/stateful_diff_command.cc27
19 files changed, 80 insertions, 55 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index ca5d16e63a..4dc7ea65fc 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -980,7 +980,7 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
rv->region()->set_position (where, (void*) this);
- _editor->session()->add_command (new StatefulDiffCommand (rv->region().get()));
+ _editor->session()->add_command (new StatefulDiffCommand (rv->region()));
}
if (changed_tracks && !_copy) {
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 6ed670509e..16773f269d 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -3180,7 +3180,7 @@ Editor::naturalize ()
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
(*i)->region()->clear_history ();
(*i)->region()->move_to_natural_position (this);
- _session->add_command (new StatefulDiffCommand ((*i)->region().get()));
+ _session->add_command (new StatefulDiffCommand ((*i)->region()));
}
commit_reversible_command ();
}
@@ -4932,7 +4932,7 @@ Editor::toggle_gain_envelope_active ()
if (arv) {
arv->region()->clear_history ();
arv->audio_region()->set_envelope_active (!arv->audio_region()->envelope_active());
- _session->add_command (new StatefulDiffCommand (arv->region().get()));
+ _session->add_command (new StatefulDiffCommand (arv->region()));
}
}
@@ -4953,7 +4953,7 @@ Editor::toggle_region_lock ()
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
(*i)->region()->clear_history ();
(*i)->region()->set_locked (!(*i)->region()->locked());
- _session->add_command (new StatefulDiffCommand ((*i)->region().get()));
+ _session->add_command (new StatefulDiffCommand ((*i)->region()));
}
_session->commit_reversible_command ();
@@ -4995,7 +4995,7 @@ Editor::toggle_region_mute ()
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
(*i)->region()->clear_history ();
(*i)->region()->set_muted (!(*i)->region()->muted());
- _session->add_command (new StatefulDiffCommand ((*i)->region().get()));
+ _session->add_command (new StatefulDiffCommand ((*i)->region()));
}
_session->commit_reversible_command ();
@@ -5015,7 +5015,7 @@ Editor::toggle_region_opaque ()
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
(*i)->region()->clear_history ();
(*i)->region()->set_opaque (!(*i)->region()->opaque());
- _session->add_command (new StatefulDiffCommand ((*i)->region().get()));
+ _session->add_command (new StatefulDiffCommand ((*i)->region()));
}
_session->commit_reversible_command ();
diff --git a/libs/ardour/ardour/pi_controller.h b/libs/ardour/ardour/pi_controller.h
index c5b7c154ac..250c943de9 100644
--- a/libs/ardour/ardour/pi_controller.h
+++ b/libs/ardour/ardour/pi_controller.h
@@ -33,7 +33,7 @@ class PIController {
out_of_bounds ();
}
- double get_ratio (int fill_level);
+ double get_ratio (int fill_level, int period_size);
void out_of_bounds();
public:
@@ -60,7 +60,7 @@ class PIChaser {
PIChaser();
~PIChaser();
- double get_ratio( nframes64_t chasetime_measured, nframes64_t chasetime, nframes64_t slavetime_measured, nframes64_t slavetime, bool in_control );
+ double get_ratio( nframes64_t chasetime_measured, nframes64_t chasetime, nframes64_t slavetime_measured, nframes64_t slavetime, bool in_control, int period_size );
void reset();
nframes64_t want_locate() { return want_locate_val; }
diff --git a/libs/ardour/ardour/session_object.h b/libs/ardour/ardour/session_object.h
index cf9ccbb3a7..069badcb6a 100644
--- a/libs/ardour/ardour/session_object.h
+++ b/libs/ardour/ardour/session_object.h
@@ -41,7 +41,7 @@ class SessionObject : public SessionHandleRef, public PBD::StatefulDestructible
public:
SessionObject (Session& session, const std::string& name)
: SessionHandleRef (session)
- , _name (X_("name"), PBD::Change (0), "")
+ , _name (X_("name"), PBD::Change (0), name)
{
add_state (_name);
}
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index ef209fad3a..9a93e45000 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -1433,7 +1433,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
if (s) {
srcs.push_back (s);
s->update_header (capture_info.front()->start, when, twhen);
- s->set_captured_for (_name.get());
+ s->set_captured_for (_name.val());
s->mark_immutable ();
if (Config->get_auto_analyse_audio()) {
Analyser::queue_source_for_analysis (s, true);
@@ -1970,7 +1970,7 @@ AudioDiskstream::rename_write_sources ()
for (chan = c->begin(), n = 0; chan != c->end(); ++chan, ++n) {
if ((*chan)->write_source != 0) {
- (*chan)->write_source->set_source_name (_name.get(), destructive());
+ (*chan)->write_source->set_source_name (_name.val(), destructive());
/* XXX what to do if one of them fails ? */
}
}
@@ -2178,7 +2178,7 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
first_fs = fs;
}
- fs->set_captured_for (_name.get());
+ fs->set_captured_for (_name.val());
}
}
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc
index a79dae5f07..0ca173570a 100644
--- a/libs/ardour/crossfade.cc
+++ b/libs/ardour/crossfade.cc
@@ -314,7 +314,7 @@ Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
start = _position;
buf += offset;
- to_write = min (_length.get(), cnt);
+ to_write = min (_length.val(), cnt);
} else {
@@ -679,7 +679,7 @@ Crossfade::get_state ()
node->add_property ("active", (_active ? "yes" : "no"));
node->add_property ("follow-overlap", (_follow_overlap ? "yes" : "no"));
node->add_property ("fixed", (_fixed ? "yes" : "no"));
- snprintf (buf, sizeof(buf), "%" PRIu32, _length.get());
+ snprintf (buf, sizeof(buf), "%" PRIu32, _length.val());
node->add_property ("length", buf);
snprintf (buf, sizeof(buf), "%" PRIu32, (uint32_t) _anchor_point);
node->add_property ("anchor-point", buf);
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 34f624f2d2..48bab25546 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -1098,7 +1098,7 @@ IO::set_name (const string& requested_name)
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
string current_name = i->name();
- current_name.replace (current_name.find (_name), _name.get().length(), name);
+ current_name.replace (current_name.find (_name), _name.val().length(), name);
i->set_name (current_name);
}
@@ -1267,7 +1267,7 @@ IO::build_legal_port_name (DataType type)
char buf1[name_size+1];
char buf2[name_size+1];
- snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.get().c_str(), suffix.c_str());
+ snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.val().c_str(), suffix.c_str());
int port_number = find_port_hole (buf1);
snprintf (buf2, name_size+1, "%s %d", buf1, port_number);
@@ -1342,9 +1342,9 @@ IO::setup_bundle ()
_bundle->remove_channels ();
if (_direction == Input) {
- snprintf(buf, sizeof (buf), _("%s in"), _name.get().c_str());
+ snprintf(buf, sizeof (buf), _("%s in"), _name.val().c_str());
} else {
- snprintf(buf, sizeof (buf), _("%s out"), _name.get().c_str());
+ snprintf(buf, sizeof (buf), _("%s out"), _name.val().c_str());
}
_bundle->set_name (buf);
uint32_t const ni = _ports.num_ports();
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index 790891a72d..11fec341b2 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -1388,7 +1388,7 @@ int
MidiDiskstream::rename_write_sources ()
{
if (_write_source != 0) {
- _write_source->set_source_name (_name.get(), destructive());
+ _write_source->set_source_name (_name.val(), destructive());
/* XXX what to do if this fails ? */
}
return 0;
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc
index fb7a7e082f..bccc32c9cb 100644
--- a/libs/ardour/midi_region.cc
+++ b/libs/ardour/midi_region.cc
@@ -51,7 +51,7 @@ using namespace PBD;
MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nframes_t length)
: Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::MIDI, 0, Region::Flag(Region::DefaultFlags|Region::External))
{
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
@@ -59,7 +59,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nfra
MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (src, start, length, name, DataType::MIDI, layer, flags)
{
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
@@ -67,7 +67,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nfra
MidiRegion::MidiRegion (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (srcs, start, length, name, DataType::MIDI, layer, flags)
{
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
@@ -76,14 +76,14 @@ MidiRegion::MidiRegion (const SourceList& srcs, nframes_t start, nframes_t lengt
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (other, offset, length, name, layer, flags)
{
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
: Region (other)
{
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
@@ -95,7 +95,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, const XMLNode& node)
}
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
assert(_type == DataType::MIDI);
}
@@ -107,7 +107,7 @@ MidiRegion::MidiRegion (const SourceList& srcs, const XMLNode& node)
}
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
- assert(_name.get().find("/") == string::npos);
+ assert(_name.val().find("/") == string::npos);
assert(_type == DataType::MIDI);
}
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index ce58d4f585..2b0efd78e1 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -230,7 +230,7 @@ MidiSource::session_saved()
if (_model && _model->edited()) {
string newname;
- const string basename = PBD::basename_nosuffix(_name.get());
+ const string basename = PBD::basename_nosuffix(_name.val());
string::size_type last_dash = basename.find_last_of("-");
if (last_dash == string::npos || last_dash == basename.find_first_of("-")) {
newname = basename + "-1";
diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc
index 64f67ba746..7c990bd654 100644
--- a/libs/ardour/mtc_slave.cc
+++ b/libs/ardour/mtc_slave.cc
@@ -429,7 +429,7 @@ MTC_Slave::speed_and_position (double& speed, nframes64_t& pos)
static double average_speed = 0;
nframes64_t ref_now = session.engine().frame_time_at_cycle_start();
- average_speed = pic->get_ratio (last.timestamp, last.position, ref_now, slave_pos, in_control );
+ average_speed = pic->get_ratio (last.timestamp, last.position, ref_now, slave_pos, in_control, session.engine().frames_per_cycle());
pic_want_locate = pic->want_locate();
diff --git a/libs/ardour/pi_controller.cc b/libs/ardour/pi_controller.cc
index baee5a972a..bdf9c27cee 100644
--- a/libs/ardour/pi_controller.cc
+++ b/libs/ardour/pi_controller.cc
@@ -56,10 +56,10 @@ PIController::~PIController ()
}
double
-PIController::get_ratio (int fill_level)
+PIController::get_ratio (int fill_level, int period_size)
{
double offset = fill_level;
- double this_catch_factor = catch_factor;
+ double this_catch_factor = catch_factor * 4096.0/(double)period_size;
// Save offset.
@@ -151,7 +151,7 @@ PIChaser::~PIChaser() {
}
double
-PIChaser::get_ratio(nframes64_t chasetime_measured, nframes64_t chasetime, nframes64_t slavetime_measured, nframes64_t slavetime, bool in_control ) {
+PIChaser::get_ratio(nframes64_t chasetime_measured, nframes64_t chasetime, nframes64_t slavetime_measured, nframes64_t slavetime, bool in_control, int period_size ) {
feed_estimator( chasetime_measured, chasetime );
std::cerr << (double)chasetime_measured/48000.0 << " " << chasetime << " " << slavetime << " ";
@@ -159,7 +159,7 @@ PIChaser::get_ratio(nframes64_t chasetime_measured, nframes64_t chasetime, nfram
double fine;
nframes64_t massaged_chasetime = chasetime + (nframes64_t)( (double)(slavetime_measured - chasetime_measured) * crude );
- fine = pic->get_ratio( slavetime - massaged_chasetime );
+ fine = pic->get_ratio( slavetime - massaged_chasetime, period_size );
if (in_control) {
if (fabs(fine-crude) > crude*speed_threshold) {
std::cout << "reset to " << crude << " fine = " << fine << "\n";
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 03d90bcf09..06437811e7 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -1197,12 +1197,12 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
/* fix problems with old sessions corrupted by impossible
values for _stretch or _shift
*/
- if (_stretch == 0.0) {
- _stretch = 1.0;
+ if (_stretch == 0.0f) {
+ _stretch = 1.0f;
}
- if (_shift == 0.0) {
- _shift = 1.0;
+ if (_shift == 0.0f) {
+ _shift = 1.0f;
}
/* note: derived classes set flags */
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 02005fc269..0cf62f4cae 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -78,6 +78,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _default_type (default_type)
{
+ cerr << "New route with n=" << name << " has name = " << _name.val() << endl;
init ();
/* add standard processors other than amp (added by ::init()) */
diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc
index 82ecc60b83..6c2621fdb9 100644
--- a/libs/ardour/session_command.cc
+++ b/libs/ardour/session_command.cc
@@ -144,7 +144,7 @@ Session::stateful_diff_command_factory (XMLNode* n)
if ((obj_T == typeid (AudioRegion).name() || obj_T == typeid (MidiRegion).name())) {
boost::shared_ptr<Region> r = RegionFactory::region_by_id (id);
if (r) {
- return new StatefulDiffCommand (r.get(), *n);
+ return new StatefulDiffCommand (r, *n);
}
}
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index 8f454d31ce..de8ce330e1 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -306,7 +306,7 @@ SndFileSource::read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const
if (sf_seek (sf, (sf_count_t) start, SEEK_SET|SFM_READ) != (sf_count_t) start) {
char errbuf[256];
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
- error << string_compose(_("SndFileSource: could not seek to frame %1 within %2 (%3)"), start, _name.get().substr (1), errbuf) << endmsg;
+ error << string_compose(_("SndFileSource: could not seek to frame %1 within %2 (%3)"), start, _name.val().substr (1), errbuf) << endmsg;
return 0;
}
@@ -316,7 +316,7 @@ SndFileSource::read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const
if (ret != file_cnt) {
char errbuf[256];
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
- cerr << string_compose(_("SndFileSource: @ %1 could not read %2 within %3 (%4) (len = %5)"), start, file_cnt, _name.get().substr (1), errbuf, _length) << endl;
+ cerr << string_compose(_("SndFileSource: @ %1 could not read %2 within %3 (%4) (len = %5)"), start, file_cnt, _name.val().substr (1), errbuf, _length) << endl;
}
return ret;
}
diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
index 5d3c98439c..02224bb5e1 100644
--- a/libs/pbd/pbd/stateful.h
+++ b/libs/pbd/pbd/stateful.h
@@ -99,20 +99,20 @@ public:
set (_current + v);
return _current;
}
-
- bool operator== (std::string const & o) const {
- return o == to_string (_current);
+
+ bool operator== (const T& other) const {
+ return _current == other;
}
- bool operator!= (std::string const & o) const {
- return o != to_string (_current);
+ bool operator!= (const T& other) const {
+ return _current != other;
}
operator T const & () const {
return _current;
}
- T const & get () const {
+ T const & val () const {
return _current;
}
@@ -165,7 +165,7 @@ protected:
template<class T>
std::ostream& operator<< (std::ostream& os, StateTemplate<T> const & s)
{
- os << s.get();
+ os << s.val();
return os;
}
@@ -190,6 +190,7 @@ public:
private:
std::string to_string (T const & v) const {
std::stringstream s;
+ s.precision (12); // in case its floating point
s << v;
return s.str ();
}
@@ -197,6 +198,7 @@ private:
T from_string (std::string const & s) const {
std::stringstream t (s);
T v;
+ t.precision (12); // in case its floating point
t >> v;
return v;
}
diff --git a/libs/pbd/pbd/stateful_diff_command.h b/libs/pbd/pbd/stateful_diff_command.h
index 41c0c70f69..43efed445d 100644
--- a/libs/pbd/pbd/stateful_diff_command.h
+++ b/libs/pbd/pbd/stateful_diff_command.h
@@ -17,6 +17,11 @@
*/
+#ifndef __pbd_stateful_diff_command_h__
+#define __pbd_stateful_diff_command_h__
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
#include "pbd/command.h"
namespace PBD
@@ -30,8 +35,8 @@ class Stateful;
class StatefulDiffCommand : public Command
{
public:
- StatefulDiffCommand (Stateful *);
- StatefulDiffCommand (Stateful *, XMLNode const &);
+ StatefulDiffCommand (boost::shared_ptr<Stateful>);
+ StatefulDiffCommand (boost::shared_ptr<Stateful>, XMLNode const &);
~StatefulDiffCommand ();
void operator() ();
@@ -40,9 +45,11 @@ public:
XMLNode& get_state ();
private:
- Stateful* _object; ///< the object in question
+ boost::weak_ptr<Stateful> _object; ///< the object in question
XMLNode* _before; ///< XML node containing the previous values of XML properties which changed
XMLNode* _after; ///< XML node containing the new values of XML properties which changed
};
};
+
+#endif /* __pbd_stateful_diff_command_h__ */
diff --git a/libs/pbd/stateful_diff_command.cc b/libs/pbd/stateful_diff_command.cc
index 1332cae4ff..bf092a6594 100644
--- a/libs/pbd/stateful_diff_command.cc
+++ b/libs/pbd/stateful_diff_command.cc
@@ -28,7 +28,7 @@ using namespace PBD;
* @param s Stateful object.
*/
-StatefulDiffCommand::StatefulDiffCommand (Stateful* s)
+StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s)
: _object (s)
{
pair<XMLNode *, XMLNode*> const p = s->diff ();
@@ -36,7 +36,7 @@ StatefulDiffCommand::StatefulDiffCommand (Stateful* s)
_after = p.second;
}
-StatefulDiffCommand::StatefulDiffCommand (Stateful* s, XMLNode const & n)
+StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s, XMLNode const & n)
: _object (s)
{
_before = new XMLNode (*n.children().front());
@@ -53,22 +53,37 @@ StatefulDiffCommand::~StatefulDiffCommand ()
void
StatefulDiffCommand::operator() ()
{
- _object->set_state (*_after, Stateful::current_state_version);
+ boost::shared_ptr<Stateful> s (_object.lock());
+
+ if (s) {
+ s->set_state (*_after, Stateful::current_state_version);
+ }
}
void
StatefulDiffCommand::undo ()
{
- _object->set_state (*_before, Stateful::current_state_version);
+ boost::shared_ptr<Stateful> s (_object.lock());
+
+ if (s) {
+ s->set_state (*_before, Stateful::current_state_version);
+ }
}
XMLNode&
StatefulDiffCommand::get_state ()
{
+ boost::shared_ptr<Stateful> s (_object.lock());
+
+ if (!s) {
+ /* XXX should we throw? */
+ return * new XMLNode("");
+ }
+
XMLNode* node = new XMLNode (X_("StatefulDiffCommand"));
- node->add_property ("obj-id", _object->id().to_s());
- node->add_property ("type-name", typeid(*_object).name());
+ node->add_property ("obj-id", s->id().to_s());
+ node->add_property ("type-name", typeid(*s.get()).name());
node->add_child_copy (*_before);
node->add_child_copy (*_after);