Skip to content

Commit

Permalink
Fix asset caching
Browse files Browse the repository at this point in the history
Closes #623
  • Loading branch information
AstraLuma committed May 18, 2021
1 parent 4833d32 commit c9a5569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ppb/assetlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,11 @@ def __new__(cls, name):
try:
return _asset_cache[(clsname, name)]
except KeyError:
inst = super().__new__(cls)
_asset_cache[(clsname, name)] = inst
return inst

def __init__(self, name):
self.name = str(name)
self._start()
self = super().__new__(cls)
self.name = str(name)
_asset_cache[(clsname, name)] = self
self._start()
return self

def __repr__(self):
return f"<{type(self).__name__} name={self.name!r}{' loaded' if self.is_loaded() else ''} at 0x{id(self):x}>"
Expand Down
2 changes: 2 additions & 0 deletions ppb/systems/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Sound(assetlib.Asset):
# This is wrapping a ctypes.POINTER(Mix_Chunk)

def background_parse(self, data):
print("Sound.background_parse", repr(self), flush=True)
file = rw_from_object(io.BytesIO(data))
# ^^^^ is a pure-python emulation, does not need cleanup.
return mix_call(
Expand Down Expand Up @@ -84,6 +85,7 @@ def allocated_channels(self, value):
mix_call(Mix_AllocateChannels, value)

def __enter__(self):
print("SoundController.__enter__", repr(self), flush=True)
super().__enter__()
mix_call(
Mix_OpenAudio,
Expand Down

0 comments on commit c9a5569

Please sign in to comment.