Skip to content

Commit 7a92ce7

Browse files
committed
Fix 1c0c915: It was still possible to have invalid undo actions by creating a branch while recording and unpaused.
1 parent dd73765 commit 7a92ce7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ private class UndoItem
9999
public List<IMovieAction> actions;
100100
public string name;
101101
public int id;
102+
103+
public UndoItem Clone()
104+
{
105+
return new()
106+
{
107+
actions = new(this.actions),
108+
name = this.name,
109+
id = this.id,
110+
};
111+
}
102112
}
103113

104114
private List<UndoItem> _history = new();
@@ -316,7 +326,12 @@ public IMovieChangeLog Clone()
316326
{
317327
TasMovieChangeLog newLog = (TasMovieChangeLog)this.MemberwiseClone();
318328
// The history list is the only thing that needs more than a shallow copy from MemberwiseClone.
319-
newLog._history = new(_history);
329+
newLog._history = new();
330+
// Clone each UndoItem because they can be mutated by MergeActions.
331+
foreach (UndoItem item in this._history)
332+
{
333+
newLog._history.Add(item.Clone());
334+
}
320335
return newLog;
321336
}
322337

0 commit comments

Comments
 (0)