all repos — mgba @ 883e7729f4071d868728e6574d21f84fcd646c49

mGBA Game Boy Advance Emulator

Python: Better protect stuff that gets gc'd
Vicki Pfau vi@endrift.com
Mon, 25 Sep 2017 00:07:51 -0700
commit

883e7729f4071d868728e6574d21f84fcd646c49

parent

bec2757dbf0ddb3d28d09353d2cc4a7aea716103

M src/platform/python/mgba/core.pysrc/platform/python/mgba/core.py

@@ -105,8 +105,13 @@ self._callbacks = CoreCallbacks()

self._core.addCoreCallbacks(self._core, self._callbacks.context) self.config = Config(ffi.addressof(native.config)) + def __del__(self): + self._wasReset = False + @cached_property def graphicsCache(self): + if not self._wasReset: + raise RuntimeError("Core must be reset first") return tile.CacheSet(self) @cached_property
M src/platform/python/mgba/gb.pysrc/platform/python/mgba/gb.py

@@ -32,8 +32,9 @@ lib.GBVideoCacheInit(cache)

lib.GBVideoCacheAssociate(cache, ffi.addressof(self._native.video)) def _deinitCache(self, cache): - self._native.video.renderer.cache = ffi.NULL lib.mCacheSetDeinit(cache) + if self._wasReset: + self._native.video.renderer.cache = ffi.NULL def reset(self): super(GB, self).reset()
M src/platform/python/mgba/gba.pysrc/platform/python/mgba/gba.py

@@ -40,8 +40,9 @@ lib.GBAVideoCacheInit(cache)

lib.GBAVideoCacheAssociate(cache, ffi.addressof(self._native.video)) def _deinitCache(self, cache): - self._native.video.renderer.cache = ffi.NULL lib.mCacheSetDeinit(cache) + if self._wasReset: + self._native.video.renderer.cache = ffi.NULL def reset(self): super(GBA, self).reset()