diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 6b1aed6268..640120516c 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -254,19 +254,13 @@ AudioStreamView::playlist_layered (boost::weak_ptr wds) return; } - cerr << "AS, call SV::modified @ " << get_microseconds() << endl; - StreamView::playlist_layered (wds); - cerr << "AS, done with SV::modified @ " << get_microseconds() << endl; - /* make sure xfades are on top and all the regionviews are stacked correctly. */ - cerr << "AS, raise xfades @ " << get_microseconds() << endl; for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { i->second->get_canvas_group()->raise_to_top(); } - cerr << "AS, done with xfades @ " << get_microseconds() << endl; } void diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 8c53fd0596..3aff2f2d18 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -336,7 +336,7 @@ StreamView::playlist_switched (boost::weak_ptr wds) ds->playlist()->LayeringChanged.connect (playlist_connections, boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr(ds)), gui_context()); ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view, this, _1), gui_context()); ds->playlist()->RegionRemoved.connect (playlist_connections, ui_bind (&StreamView::remove_region_view, this, _1), gui_context()); - ds->playlist()->ContentsChanged.connect (playlist_connections, boost::bind (&StreamView::redisplay_diskstream, this), gui_context()); + // ds->playlist()->ContentsChanged.connect (playlist_connections, boost::bind (&StreamView::redisplay_diskstream, this), gui_context()); } void diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 7213c99397..38469f4723 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -296,6 +296,8 @@ class Playlist : public SessionObject int move_region_to_layer (layer_t, boost::shared_ptr r, int dir); void relayer (); + void begin_undo (); + void end_undo (); void unset_freeze_parent (Playlist*); void unset_freeze_child (Playlist*); diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 21fda237cb..97ac214fdc 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -625,8 +625,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_ _envelope->set_max_xval (_length); _envelope->truncate_end (_length); - cerr << _name << " envelope changd\n"; - } else if (child->name() == "FadeIn") { @@ -648,7 +646,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_ set_fade_in_active (false); } } - cerr << _name << " fadein changd\n"; } else if (child->name() == "FadeOut") { @@ -670,7 +667,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_ set_fade_out_active (false); } } - cerr << _name << " fadeout changd\n"; } } diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index f3a9c99497..815970a276 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -278,6 +278,9 @@ Playlist::init (bool hide) freeze_length = 0; _explicit_relayering = false; + _session.history().BeginUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::begin_undo, this)); + _session.history().EndUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::end_undo, this)); + ContentsChanged.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this)); } @@ -320,6 +323,18 @@ Playlist::set_name (const string& str) the lock (e.g. to read from the playlist). ***********************************************************************/ +void +Playlist::begin_undo () +{ + freeze (); +} + +void +Playlist::end_undo () +{ + thaw (); +} + void Playlist::freeze () { @@ -357,9 +372,7 @@ Playlist::notify_contents_changed () pending_contents_change = true; } else { pending_contents_change = false; - cerr << _name << "send contents change @ " << get_microseconds() << endl; ContentsChanged(); /* EMIT SIGNAL */ - cerr << _name << "done with cc @ " << get_microseconds() << endl; } } @@ -370,9 +383,7 @@ Playlist::notify_layering_changed () pending_layering = true; } else { pending_layering = false; - cerr << _name << "send layering @ " << get_microseconds() << endl; LayeringChanged(); /* EMIT SIGNAL */ - cerr << _name << "done with layering @ " << get_microseconds() << endl; } } @@ -429,9 +440,7 @@ Playlist::notify_region_added (boost::shared_ptr r) LengthChanged (); /* EMIT SIGNAL */ pending_contents_change = false; RegionAdded (boost::weak_ptr (r)); /* EMIT SIGNAL */ - cerr << _name << "send3 contents changed @ " << get_microseconds() << endl; ContentsChanged (); /* EMIT SIGNAL */ - cerr << _name << "done contents changed @ " << get_microseconds() << endl; } } @@ -444,9 +453,7 @@ Playlist::notify_length_changed () pending_length = false; LengthChanged(); /* EMIT SIGNAL */ pending_contents_change = false; - cerr << _name << "send4 contents change @ " << get_microseconds() << endl; ContentsChanged (); /* EMIT SIGNAL */ - cerr << _name << "done contents change @ " << get_microseconds() << endl; } } @@ -491,12 +498,12 @@ Playlist::flush_notifications () for (s = pending_removes.begin(); s != pending_removes.end(); ++s) { remove_dependents (*s); - cerr << _name << " sends RegionRemoved\n"; + // cerr << _name << " sends RegionRemoved\n"; RegionRemoved (boost::weak_ptr (*s)); /* EMIT SIGNAL */ } for (s = pending_adds.begin(); s != pending_adds.end(); ++s) { - cerr << _name << " sends RegionAdded\n"; + // cerr << _name << " sends RegionAdded\n"; RegionAdded (boost::weak_ptr (*s)); /* EMIT SIGNAL */ dependent_checks_needed.insert (*s); } @@ -504,13 +511,13 @@ Playlist::flush_notifications () if (check_length) { if (old_length != _get_maximum_extent()) { pending_length = true; - cerr << _name << " length has changed\n"; + // cerr << _name << " length has changed\n"; } } if (pending_length || (freeze_length != _get_maximum_extent())) { pending_length = false; - cerr << _name << " sends LengthChanged\n"; + // cerr << _name << " sends LengthChanged\n"; LengthChanged(); /* EMIT SIGNAL */ } @@ -519,9 +526,9 @@ Playlist::flush_notifications () relayer (); } pending_contents_change = false; - cerr << _name << " sends 5 contents change @ " << get_microseconds() << endl; + // cerr << _name << " sends 5 contents change @ " << get_microseconds() << endl; ContentsChanged (); /* EMIT SIGNAL */ - cerr << _name << "done contents change @ " << get_microseconds() << endl; + // cerr << _name << "done contents change @ " << get_microseconds() << endl; } for (s = dependent_checks_needed.begin(); s != dependent_checks_needed.end(); ++s) { @@ -529,7 +536,7 @@ Playlist::flush_notifications () } if (!pending_range_moves.empty ()) { - cerr << _name << " sends RangesMoved\n"; + // cerr << _name << " sends RangesMoved\n"; RangesMoved (pending_range_moves); } @@ -1530,9 +1537,7 @@ Playlist::clear (bool with_signals) pending_length = false; LengthChanged (); pending_contents_change = false; - cerr << _name << "send2 contents change @ " << get_microseconds() << endl; ContentsChanged (); - cerr << _name << "done with contents changed @ " << get_microseconds() << endl; } } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 9cd8d49411..d7b1eec2f7 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1144,8 +1144,6 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang { const XMLProperty* prop; - cerr << "about to call ::set_properties for an XMLNode\n"; - what_changed = set_properties (node); if ((prop = node.property (X_("id")))) { diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index bb910252c3..6eb9e00056 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -107,6 +107,8 @@ class UndoHistory : public PBD::ScopedConnectionList void set_depth (uint32_t); PBD::Signal0 Changed; + PBD::Signal0 BeginUndoRedo; + PBD::Signal0 EndUndoRedo; private: bool _clearing; diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 223c533ff8..a4042a7e13 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -122,25 +122,15 @@ UndoTransaction::operator() () void UndoTransaction::undo () { - struct timeval start, end, diff; - gettimeofday (&start, 0); for (list::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) { (*i)->undo(); } - gettimeofday (&end, 0); - timersub (&end, &start, &diff); - cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl; } void UndoTransaction::redo () { - struct timeval start, end, diff; - gettimeofday (&start, 0); (*this)(); - gettimeofday (&end, 0); - timersub (&end, &start, &diff); - cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl; } XMLNode &UndoTransaction::get_state() @@ -161,6 +151,20 @@ XMLNode &UndoTransaction::get_state() return *node; } +class UndoRedoSignaller { +public: + UndoRedoSignaller (UndoHistory& uh) + : _history (uh) { + _history.BeginUndoRedo(); + } + ~UndoRedoSignaller() { + _history.EndUndoRedo(); + } + +private: + UndoHistory& _history; +}; + UndoHistory::UndoHistory () { _clearing = false; @@ -242,32 +246,70 @@ UndoHistory::remove (UndoTransaction* const ut) void UndoHistory::undo (unsigned int n) { - while (n--) { - if (UndoList.size() == 0) { - return; - } - UndoTransaction* ut = UndoList.back (); - UndoList.pop_back (); - ut->undo (); - RedoList.push_back (ut); + if (n == 0) { + return; } + struct timeval start, end, diff; + gettimeofday (&start, 0); + + { + UndoRedoSignaller exception_safe_signaller (*this); + + while (n--) { + if (UndoList.size() == 0) { + return; + } + UndoTransaction* ut = UndoList.back (); + UndoList.pop_back (); + ut->undo (); + RedoList.push_back (ut); + } + gettimeofday (&end, 0); + timersub (&end, &start, &diff); + cerr << "Undo-pre-signals took " << diff.tv_sec << '.' << diff.tv_usec << endl; + + } + + gettimeofday (&end, 0); + timersub (&end, &start, &diff); + cerr << "Undo took " << diff.tv_sec << '.' << diff.tv_usec << endl; + Changed (); /* EMIT SIGNAL */ } void UndoHistory::redo (unsigned int n) { - while (n--) { - if (RedoList.size() == 0) { - return; - } - UndoTransaction* ut = RedoList.back (); - RedoList.pop_back (); - ut->redo (); - UndoList.push_back (ut); + if (n == 0) { + return; } + struct timeval start, end, diff; + gettimeofday (&start, 0); + + { + UndoRedoSignaller exception_safe_signaller (*this); + + while (n--) { + if (RedoList.size() == 0) { + return; + } + UndoTransaction* ut = RedoList.back (); + RedoList.pop_back (); + ut->redo (); + UndoList.push_back (ut); + } + gettimeofday (&end, 0); + timersub (&end, &start, &diff); + cerr << "Redo-pre-signals took " << diff.tv_sec << '.' << diff.tv_usec << endl; + } + + gettimeofday (&end, 0); + timersub (&end, &start, &diff); + cerr << "Redo took " << diff.tv_sec << '.' << diff.tv_usec << endl; + + EndUndoRedo (); /* EMIT SIGNAL */ Changed (); /* EMIT SIGNAL */ }