The automatic function detection seems to register also functions that are outside the valid areas. This causes errors when saving the file afterwards:
Traceback (most recent call last):
File "./ScratchABit.py", line 1032, in <module>
saveload.save_state(project_dir)
File "/home/user/scratch/ScratchABit/scratchabit/saveload.py", line 32, in save_state
engine.ADDRESS_SPACE.save_addr_props(project_dir + "/project.aprops")
File "/home/user/scratch/ScratchABit/scratchabit/engine.py", line 683, in save_addr_props
while addr > areas[area_i][END]:
IndexError: list index out of range
The following patch logs the offending function definition:
--- a/scratchabit/engine.py
+++ b/scratchabit/engine.py
@@ -680,8 +680,11 @@ class AddressSpace:
if addr > area_end:
stream.close()
area_i += 1
- while addr > areas[area_i][END]:
+ while area_i<len(areas) and addr > areas[area_i][END]:
area_i += 1
+ if area_i>=len(areas):
+ log.debug("addr not valid (%x,%s)", addr, props.get("label"))
+ assert area_i<len(areas)
The automatic function detection seems to register also functions that are outside the valid areas. This causes errors when saving the file afterwards: