I tested workaround, index for win to delete is saved and win is deleted from seq outside of iterator.
Before:
proc wAppWindowDelete(win: wWindow) =
wTheApp.mWindowTable.del(win.mHwnd)
for index, w in wTheApp.mTopLevelWindowList:
if w == win:
wTheApp.mTopLevelWindowList.del(index)
Now (updated):
proc wAppWindowDelete(win: wWindow) =
wTheApp.mWindowTable.del(win.mHwnd)
var indexesToDelete: seq[int]
for index, w in wTheApp.mTopLevelWindowList:
if w == win:
indexesToDelete.add(index)
while(indexesToDelete.len > 0):
# delete from wTheApp.mTopLevelWindowList in reverse order to keep indexes intact
wTheApp.mTopLevelWindowList.del(indexesToDelete.pop())
P.S. I worry that there may be other places with the same problem
Runtime error occurs because new rule about seq's modification white iterate through it
For example: wNim/private/wApp.nim, proc wAppWindowDelete, line 73
I tested workaround, index for win to delete is saved and win is deleted from seq outside of iterator.
Before:
Now (updated):
P.S. I worry that there may be other places with the same problem