Python: Make sure GB link object isn't GC'd before GB object

This commit is contained in:
Vicki Pfau 2019-02-20 19:45:54 -08:00
parent 237c891ad2
commit e363e7ed02
2 changed files with 6 additions and 1 deletions

View File

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

View File

@ -27,6 +27,7 @@ class GB(Core):
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 @@ class GB(Core):
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")