diff --git a/ppb/assetlib.py b/ppb/assetlib.py index 864070ab..f14a655f 100644 --- a/ppb/assetlib.py +++ b/ppb/assetlib.py @@ -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}>" diff --git a/ppb/systems/sound.py b/ppb/systems/sound.py index 7c541cba..df3ea56d 100644 --- a/ppb/systems/sound.py +++ b/ppb/systems/sound.py @@ -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( @@ -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,