Python: Fix crash when deleting files owned by library
Vicki Pfau vi@endrift.com
Wed, 20 Feb 2019 19:45:11 -0800
3 files changed,
15 insertions(+),
3 deletions(-)
M
CHANGES
→
CHANGES
@@ -16,6 +16,7 @@ - Switch: Fix gyroscope orientation (fixes mgba.io/i/1300)
- GBA SIO: Prevent writing read-only multiplayer bits - Qt: Fix color picking in sprite view (fixes mgba.io/i/1307) - GB: Fix crash when accessing SRAM if no save loaded and cartridge has no SRAM + - Python: Fix crash when deleting files owned by library Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash
M
src/platform/python/mgba/core.py
→
src/platform/python/mgba/core.py
@@ -180,11 +180,17 @@ return bool(self._core.loadROM(self._core, vfile.handle))
@protected def load_bios(self, vfile, id=0): - return bool(self._core.loadBIOS(self._core, vfile.handle, id)) + res = bool(self._core.loadBIOS(self._core, vfile.handle, id)) + if res: + vfile._claimed = True + return res @protected def load_save(self, vfile): - return bool(self._core.loadSave(self._core, vfile.handle)) + res = bool(self._core.loadSave(self._core, vfile.handle)) + if res: + vfile._claimed = True + return res @protected def load_temporary_save(self, vfile):
M
src/platform/python/mgba/vfs.py
→
src/platform/python/mgba/vfs.py
@@ -112,11 +112,16 @@ class VFile:
def __init__(self, vf, _no_gc=None): self.handle = vf self._no_gc = _no_gc + self._claimed = False def __del__(self): - self.close() + if not self._claimed: + self.close() def close(self): + if self._claimed: + return False + self._claimed = True return bool(self.handle.close(self.handle)) def seek(self, offset, whence):