Closed pmer closed 7 years ago
I added https://github.com/seisatsu/Driftwood/commit/8af12c457c17f4f3b8a86127da123694359fdcaa to spot them.
Who terminates the font if the cache is disabled?
If you want resource sharing to work while the cache is disabled you'll need to do reference counting. Then we can replace this self.font = None
with self.font.deref()
.
Otherwise if the policy is that there's no resource sharing when the cache is disabled then you'll want:
if cache disabled:
self.font._terminate()
Actually I think we need reference counting even if the cache is enabled. Otherwise the cache might call the destructor after the cache entry times out.
Let me check if this is indeed the case.
UPDATE: Yep. See #111.
@seisatsu Why do we allow the cache be disabled? I am having a hard time justifying it to myself.
I am working on fixing the CacheManager, but I don't plan to support actually disabling the cache because this simplifies the logic & code.
Also since it's unlikely that people will disable the cache it wouldn't have gotten tested much and would have been at risk to develop bugs.
To achieve a result similar to disabling the cache you can set the expiration time to something low, such as 10 seconds.
This PR can be automatically merged.
But I'd like to say something while I'm here. Fonts & other cache-able resources (images, sounds, etc) shouldn't be terminated except by CacheManager.
This PR fixes the font reloading issue. A font will now only be loaded once. (Try leaving blue1 and coming back.) It looks like a similar thing might be going on in other places of the code, but I haven't checked. If you see any others, correct them!