Python: Fix crash when deleting files owned by library

This commit is contained in:
Vicki Pfau 2019-02-20 19:45:11 -08:00
parent 3a8ff86d6b
commit f3efd37264
3 changed files with 15 additions and 3 deletions

View File

@ -16,6 +16,7 @@ Bugfixes:
- 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

View File

@ -180,11 +180,17 @@ class Core(object):
@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):

View File

@ -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):