restore correct behaviour of undo/redo for tempo map drags
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 4 Jan 2012 20:40:06 +0000 (20:40 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 4 Jan 2012 20:40:06 +0000 (20:40 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11162 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h

index e07844f7a9091f15f867d25fdaa3943fad7624fa..feddeb8e6ca1e823bdcb211682972e2cee367132 100644 (file)
@@ -1953,6 +1953,8 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
 
                if (!_copy) {
                        TempoMap& map (_editor->session()->tempo_map());
+                       /* get current state */
+                       before_state = &map.get_state();
                        /* remove the section while we drag it */
                        map.remove_meter (section, true);
                }
@@ -1987,13 +1989,12 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
 
        } else {
                _editor->begin_reversible_command (_("move meter mark"));
-               XMLNode &before = map.get_state();
 
                /* we removed it before, so add it back now */
                
                map.add_meter (_marker->meter(), when);
                XMLNode &after = map.get_state();
-               _editor->session()->add_command(new MementoCommand<TempoMap>(map, &before, &after));
+               _editor->session()->add_command(new MementoCommand<TempoMap>(map, before_state, &after));
                _editor->commit_reversible_command ();
        }
 
@@ -2071,6 +2072,8 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
 
                if (!_copy) {
                        TempoMap& map (_editor->session()->tempo_map());
+                       /* get current state */
+                       before_state = &map.get_state();
                        /* remove the section while we drag it */
                        map.remove_tempo (section, true);
                }
@@ -2105,11 +2108,10 @@ TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
 
        } else {
                _editor->begin_reversible_command (_("move tempo mark"));
-               XMLNode &before = map.get_state();
                /* we removed it before, so add it back now */
                map.add_tempo (_marker->tempo(), when);
                XMLNode &after = map.get_state();
-               _editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after));
+               _editor->session()->add_command (new MementoCommand<TempoMap>(map, before_state, &after));
                _editor->commit_reversible_command ();
        }
 
index 4170315294c20f7279a680ab1b27e5e719326982..6e055a6344a4c612d318bbe46c5e4c9f592a1584 100644 (file)
@@ -570,6 +570,7 @@ public:
 private:
        MeterMarker* _marker;
        bool _copy;
+       XMLNode* before_state;
 };
 
 /** Tempo marker drag */
@@ -596,6 +597,7 @@ public:
 private:
        TempoMarker* _marker;
        bool _copy;
+       XMLNode* before_state;
 };