all repos — mgba @ f3efd3726470ca3e46209a58e8443f80cc891f3c

mGBA Game Boy Advance Emulator

Python: Fix crash when deleting files owned by library
Vicki Pfau vi@endrift.com
Wed, 20 Feb 2019 19:45:11 -0800
commit

f3efd3726470ca3e46209a58e8443f80cc891f3c

parent

3a8ff86d6b5a940630f3cd5d041ab3d13413214f

3 files changed, 15 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.pysrc/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.pysrc/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):