More _reversible_command() auditing in the gui.
authornick_m <mainsbridge@gmail.com>
Tue, 16 Jun 2015 23:26:40 +0000 (09:26 +1000)
committernick_m <mainsbridge@gmail.com>
Tue, 16 Jun 2015 23:54:23 +0000 (09:54 +1000)
- try to keep begin/commit pairs in the same file where possible.

gtk2_ardour/automation_line.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/midi_time_axis.cc
gtk2_ardour/region_editor.cc

index 069a82315508f8af9b5394d92ba1e54428b900b8..a354afeeb6de1a0cd4ad070e02c42a9cc4715da0 100644 (file)
@@ -466,7 +466,6 @@ AutomationLine::string_to_fraction (string const & s) const
 void
 AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction)
 {
-       trackview.editor().begin_reversible_command (_("automation event move"));
        trackview.editor().session()->add_command (
                new MementoCommand<AutomationList> (memento_command_binder(), &get_state(), 0));
 
@@ -492,7 +491,6 @@ AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction)
 void
 AutomationLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
 {
-       trackview.editor().begin_reversible_command (_("automation range move"));
        trackview.editor().session()->add_command (
                new MementoCommand<AutomationList> (memento_command_binder (), &get_state(), 0));
 
@@ -512,7 +510,6 @@ AutomationLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
 void
 AutomationLine::start_drag_multiple (list<ControlPoint*> cp, float fraction, XMLNode* state)
 {
-       trackview.editor().begin_reversible_command (_("automation range move"));
        trackview.editor().session()->add_command (
                new MementoCommand<AutomationList> (memento_command_binder(), state, 0));
 
index d3ed92a97cb3802ddb0d30219bd3c652f52b6d42..ab08f7f10b3bf2c3c23124b2df92e1be39b96c6d 100644 (file)
@@ -3479,7 +3479,7 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred)
                fade_length = pos - region->position();
        }
 
-       _editor->begin_reversible_command (_("change fade in length"));
+       bool in_command = false;
 
        for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
 
@@ -3495,11 +3495,17 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred)
                tmp->audio_region()->set_fade_in_length (fade_length);
                tmp->audio_region()->set_fade_in_active (true);
 
+               if (!in_command) {
+                       _editor->begin_reversible_command (_("change fade in length"));
+                       in_command = true;
+               }
                XMLNode &after = alist->get_state();
                _editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
        }
 
-       _editor->commit_reversible_command ();
+       if (in_command) {
+               _editor->commit_reversible_command ();
+       }
 }
 
 void
@@ -3598,7 +3604,7 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred)
                fade_length = region->last_frame() - pos;
        }
 
-       _editor->begin_reversible_command (_("change fade out length"));
+       bool in_command = false;
 
        for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
 
@@ -3614,11 +3620,17 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred)
                tmp->audio_region()->set_fade_out_length (fade_length);
                tmp->audio_region()->set_fade_out_active (true);
 
+               if (!in_command) {
+                       _editor->begin_reversible_command (_("change fade out length"));
+                       in_command = false;
+               }
                XMLNode &after = alist->get_state();
                _editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
        }
 
-       _editor->commit_reversible_command ();
+       if (in_command) {
+               _editor->commit_reversible_command ();
+       }
 }
 
 void
@@ -3952,8 +3964,8 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
 
        _editor->_dragging_edit_point = false;
 
-       _editor->begin_reversible_command ( _("move marker") );
        XMLNode &before = _editor->session()->locations()->get_state();
+       bool in_command = false;
 
        MarkerSelection::iterator i;
        CopiedLocationInfo::iterator x;
@@ -3968,9 +3980,12 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
                if (location) {
 
                        if (location->locked()) {
-                               return;
+                               continue;
+                       }
+                       if (!in_command) {
+                               _editor->begin_reversible_command ( _("move marker") );
+                               in_command = true;
                        }
-
                        if (location->is_mark()) {
                                location->set_start (((*x).location)->start());
                        } else {
@@ -3979,9 +3994,11 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
                }
        }
 
-       XMLNode &after = _editor->session()->locations()->get_state();
-       _editor->session()->add_command(new MementoCommand<Locations>(*(_editor->session()->locations()), &before, &after));
-       _editor->commit_reversible_command ();
+       if (in_command) {
+               XMLNode &after = _editor->session()->locations()->get_state();
+               _editor->session()->add_command(new MementoCommand<Locations>(*(_editor->session()->locations()), &before, &after));
+               _editor->commit_reversible_command ();
+       }
 }
 
 void
@@ -4044,7 +4061,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
        setup_snap_delta (pos);
 
        float const fraction = 1 - (_point->get_y() / _point->line().height());
-
+       _editor->begin_reversible_command (_("automation event move"));
        _point->line().start_drag_single (_point, _fixed_grab_x, fraction);
 
        show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction));
@@ -4190,7 +4207,7 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
        _fixed_grab_y = cy;
 
        double fraction = 1.0 - (cy / _line->height());
-
+       _editor->begin_reversible_command (_("automation range move"));
        _line->start_drag_line (before, after, fraction);
 
        show_verbose_cursor_text (_line->get_verbose_cursor_string (fraction));
@@ -5583,7 +5600,7 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
        if (_nothing_to_drag) {
                return;
        }
-
+       _editor->begin_reversible_command (_("automation range move"));
        for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
                i->line->start_drag_multiple (i->points, y_fraction (i->line, current_pointer_y()), i->state);
        }
index be475216c17e0e9c57f94dd8f16257f690f28988..e412b82c32d10f5ef569b0d0c78b9e7ebba4eb32 100644 (file)
@@ -1509,8 +1509,9 @@ boost::shared_ptr<MidiRegion>
 MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit)
 {
        Editor* real_editor = dynamic_cast<Editor*> (&_editor);
-
-       real_editor->begin_reversible_command (Operations::create_region);
+       if (commit) {
+               real_editor->begin_reversible_command (Operations::create_region);
+       }
        playlist()->clear_changes ();
 
        real_editor->snap_to (pos, RoundNearest);
index 16888fb6880d2d7160d60eeda70aeb240abc58a6..e41e012ce6a760cd70e6f00991bfacfa24218dc1 100644 (file)
@@ -270,33 +270,41 @@ RegionEditor::connect_editor_events ()
 void
 RegionEditor::position_clock_changed ()
 {
-       PublicEditor::instance().begin_reversible_command (_("change region start position"));
-
+       bool in_command = false;
        boost::shared_ptr<Playlist> pl = _region->playlist();
 
        if (pl) {
+               PublicEditor::instance().begin_reversible_command (_("change region start position"));
+               in_command = true;
+
                _region->clear_changes ();
                _region->set_position (position_clock.current_time());
                _session->add_command(new StatefulDiffCommand (_region));
        }
 
-       PublicEditor::instance().commit_reversible_command ();
+       if (in_command) {
+               PublicEditor::instance().commit_reversible_command ();
+       }
 }
 
 void
 RegionEditor::end_clock_changed ()
 {
-       PublicEditor::instance().begin_reversible_command (_("change region end position"));
-
+       bool in_command = false;
        boost::shared_ptr<Playlist> pl = _region->playlist();
 
        if (pl) {
+               PublicEditor::instance().begin_reversible_command (_("change region end position"));
+               in_command = true;
+
                 _region->clear_changes ();
                _region->trim_end (end_clock.current_time());
                _session->add_command(new StatefulDiffCommand (_region));
        }
 
-       PublicEditor::instance().commit_reversible_command ();
+       if (in_command) {
+               PublicEditor::instance().commit_reversible_command ();
+       }
 
        end_clock.set (_region->position() + _region->length() - 1, true);
 }
@@ -305,18 +313,21 @@ void
 RegionEditor::length_clock_changed ()
 {
        framecnt_t frames = length_clock.current_time();
-
-       PublicEditor::instance().begin_reversible_command (_("change region length"));
-
+       bool in_command = false;
        boost::shared_ptr<Playlist> pl = _region->playlist();
 
        if (pl) {
-                _region->clear_changes ();
+               PublicEditor::instance().begin_reversible_command (_("change region length"));
+               in_command = true;
+
+               _region->clear_changes ();
                _region->trim_end (_region->position() + frames - 1);
                _session->add_command(new StatefulDiffCommand (_region));
        }
 
-       PublicEditor::instance().commit_reversible_command ();
+       if (in_command) {
+               PublicEditor::instance().commit_reversible_command ();
+       }
 
        length_clock.set (_region->length());
 }