Author Topic: Support undo for paste  (Read 998 times)

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2868
Support undo for paste
« on: October 17, 2016, 10:42:54 PM »
The following exercise in copy & paste adds support for undo functionality for the ADM_EditorSegment::pasteFromClipBoard function.

Code: [Select]
diff --git a/avidemux/common/ADM_editor/src/ADM_segment.cpp b/avidemux/common/ADM_editor/src/ADM_segment.cpp
index eb0e450..122a00d 100644
--- a/avidemux/common/ADM_editor/src/ADM_segment.cpp
+++ b/avidemux/common/ADM_editor/src/ADM_segment.cpp
@@ -898,6 +898,7 @@ bool        ADM_EditorSegment::pasteFromClipBoard(uint64_t currentTime)
     uint32_t startSeg;
     uint64_t startSegTime;
     convertLinearTimeToSeg(  currentTime, &startSeg,&startSegTime);   
+    ListOfSegments tmp=segments;
     ListOfSegments newSegs;
     int n=segments.size();
     for(int i=0;i<n;i++)
@@ -929,6 +930,7 @@ bool        ADM_EditorSegment::pasteFromClipBoard(uint64_t currentTime)
     }
     segments=newSegs;
     updateStartTime();
+    undoSegments.push_back(tmp);
     return true;
 }
 

The paste from clipboard function would need some love anyway, going to the first frame and pasting from clipboard results in a severely broken video (inaccessible parts) in most cases (not related to this patch). Luckily the new undo function helps out of the misery :)

I hope to extend ACT_Undo with some marker A/B and current position keeping luxury later.