Skip to content

Commit

Permalink
Fix queue items referencing the same object by making a deep copy #107
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Apr 25, 2024
1 parent ef8c117 commit 7a3a39c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,11 @@ private void AddToQueue(string identifier, bool skipSubs)
queueElement.FrameCount += queueElement.FrameCount;
}

// We want to loose all object references, only took 3 hours to figure this out
var queueClone = Queue.QueueElement.DeepCopy(queueElement);

// Add to Queue
mainWindow.QueueTabControl.ListBoxQueue.Items.Add(queueElement);
mainWindow.QueueTabControl.ListBoxQueue.Items.Add(queueClone);

Directory.CreateDirectory(Path.Combine(Global.AppData, "NEAV1E", "Queue"));

Expand Down
7 changes: 7 additions & 0 deletions NotEnoughAV1Encodes/Queue/QueueElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,12 @@ private static string GetBetween(string strSource, string strStart, string strEn
}
return "0";
}

public static QueueElement DeepCopy(QueueElement queueElement)
{
// Cursed
var serialized = JsonConvert.SerializeObject(queueElement);
return JsonConvert.DeserializeObject<QueueElement>(serialized);
}
}
}

0 comments on commit 7a3a39c

Please sign in to comment.