reference counting fixes

This commit is contained in:
Adam Jensen 2023-08-01 22:02:44 +01:00
parent 2353178ba1
commit ebe4df653f
4 changed files with 8 additions and 5 deletions

View File

@ -201,7 +201,7 @@ SoundHandle SoundPlexCollection::StartPaused( // 178
if (plex) {
// TODO
m_plexes.push_back(owner);
m_plexes.emplace_back(owner);
// TODO
return owner; // calls cdc::Handle<SoundOwner>::Handle(SoundOwner*)

View File

@ -57,7 +57,7 @@ void SoundPlexWave::End(SoundPlexWave::EndType end) {
case k4:
case k5:
case k6:
delete m_voice; // call VoiceImpl::~VoiceImpl
delete static_cast<VoiceImpl*>(m_voice); // call VoiceImpl::~VoiceImpl
m_voice = nullptr;
default:
return;

View File

@ -240,6 +240,7 @@ void VoiceCollection::Remove(VoiceImpl *voice) { // line 1260
// link0 -> voice0
// ...
VoiceImpl *voice0 = *nextIt;
m_voices.erase(voice->it);
// iterator <- (voice1)
@ -248,7 +249,7 @@ void VoiceCollection::Remove(VoiceImpl *voice) { // line 1260
// link0 -> voice0
// ...
nextIt->it = voice->it;
voice0->it = voice->it;
// iterator <- (voice1)
// | `---.

View File

@ -90,7 +90,7 @@ private:
friend void InitHandlePool(uint32_t count);
friend bool IsHandlePoolValid();
HandleData() : m_object(nullptr), m_refCount(9) {} // line 297
HandleData() : m_object(nullptr), m_refCount(0) {} // line 297
HandleData(HandleData const&); // line 298
HandleData& operator=(HandleData const&); // line 299
@ -117,8 +117,10 @@ public:
inline HandleOwner::HandleOwner() : m_handle(0) {} // line 345
inline HandleOwner::~HandleOwner() { // ?
if (m_handle)
if (m_handle) {
HandleData::s_handles[m_handle].m_object = nullptr;
HandleData::s_handles[m_handle].RemReference();
}
}
inline void HandleOwner::CreateHandle(void *object) { // line 364