all repos — mgba @ 237c891ad26df85c2d200086e8535b6fcccba381

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

237c891ad26df85c2d200086e8535b6fcccba381

parent

5c42c5dcb7e9ae6f669768d480f5217955ad1726

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

jump to
M CHANGESCHANGES

@@ -10,6 +10,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 Video: Improve sprite cycle counting (fixes mgba.io/i/1274)
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):