Make a copy of the queue for iterating and removing

This commit is contained in:
Xpl0itU 2024-06-19 19:07:57 +02:00
parent bb41e9612f
commit 6c1ccae2c6

View file

@ -191,7 +191,9 @@ func (qp *QueuePane) IsTitleInQueue(title wiiudownloader.TitleEntry) bool {
}
func (qp *QueuePane) ForEachRemoving(f func(wiiudownloader.TitleEntry)) {
for _, title := range qp.titleQueue {
titleQueueCopy := make([]wiiudownloader.TitleEntry, len(qp.titleQueue))
copy(titleQueueCopy, qp.titleQueue)
for _, title := range titleQueueCopy {
f(title)
qp.RemoveTitle(title)
}