Python: Better protect stuff that gets gc'd

This commit is contained in:
Vicki Pfau 2017-09-25 00:07:51 -07:00
parent bec2757dbf
commit 883e7729f4
3 changed files with 9 additions and 2 deletions

View File

@ -105,8 +105,13 @@ class Core(object):
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

View File

@ -32,8 +32,9 @@ class GB(Core):
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()

View File

@ -40,8 +40,9 @@ class GBA(Core):
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()