Python: Make sure GB link object isn't GC'd before GB object
Vicki Pfau vi@endrift.com
Wed, 20 Feb 2019 19:45:54 -0800
2 files changed,
6 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -17,6 +17,7 @@ - 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 + - Python: Make sure GB link object isn't GC'd before GB object Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash
M
src/platform/python/mgba/gb.py
→
src/platform/python/mgba/gb.py
@@ -27,6 +27,7 @@ self._native = ffi.cast("struct GB*", native.board)
self.sprites = GBObjs(self) self.cpu = LR35902Core(self._core.cpu) self.memory = None + self._link = None @needs_reset def _init_cache(self, cache):@@ -43,10 +44,13 @@ super(GB, self)._load()
self.memory = GBMemory(self._core) def attach_sio(self, link): + self._link = link lib.GBSIOSetDriver(ffi.addressof(self._native.sio), link._native) def __del__(self): - lib.GBSIOSetDriver(ffi.addressof(self._native.sio), ffi.NULL) + if self._link: + lib.GBSIOSetDriver(ffi.addressof(self._native.sio), ffi.NULL) + self._link = None create_callback("GBSIOPythonDriver", "init")