Plug memory leaks of 1st level of Information Center

This commit is contained in:
Anonymous Maarten 2026-01-06 02:26:31 +01:00
parent bd537c3f1b
commit 7a1d52e8e3
8 changed files with 23 additions and 20 deletions

View File

@ -203,6 +203,8 @@ LegoGameState::~LegoGameState()
}
delete[] m_savePath;
delete LegoOmni::GetInstance()->GetUserActor();
}
// FUNCTION: LEGO1 0x10039780

View File

@ -157,6 +157,7 @@ void LegoPhonemePresenter::EndAction()
TextureContainer()->EraseCached(phoneme->GetCachedTextureInfo());
TextureContainer()->EraseCached(phoneme->GetTextureInfo());
cursor.Destroy();
phoneme = NULL;
}
else {
phoneme->SetCount(phoneme->GetCount() - 1);
@ -166,6 +167,9 @@ void LegoPhonemePresenter::EndAction()
if (!m_isPartOfAnimMM) {
CharacterManager()->ReleaseActor(m_roiName.GetData());
}
} else {
delete phoneme;
phoneme = NULL;
}
}
}

View File

@ -119,7 +119,7 @@ void LegoTextureContainer::EraseCached(LegoTextureInfo* p_textureInfo)
if ((*it).first == p_textureInfo) {
(*it).second = FALSE;
if (p_textureInfo->m_texture->Release() == TRUE) {
if (p_textureInfo->m_texture->Release() == 1) {
delete p_textureInfo;
m_cached.erase(it);
}

View File

@ -43,7 +43,13 @@ inline Result LightSetColor(IDirect3DRMFrame2* pLight, float r, float g, float b
result = ResultVal(lights->GetElement(0, &light));
assert(Succeeded(result));
return ResultVal(light->SetColorRGB(r, g, b));
lights->Release();
result = ResultVal(light->SetColorRGB(r, g, b));
light->Release();
return result;
}
// FUNCTION: LEGO1 0x100a37e0

View File

@ -25,16 +25,6 @@ HRESULT Direct3DRMMeshImpl::Clone(int flags, GUID iid, void** object)
auto* clone = new Direct3DRMMeshImpl(*this);
for (auto& group : clone->m_groups) {
// Reusing the same texture and material on the new mesh instead of cloning them might not be correct
if (group.texture) {
group.texture->AddRef();
}
if (group.material) {
group.material->AddRef();
}
}
*object = static_cast<IDirect3DRMMesh*>(clone);
return DD_OK;
}
@ -154,12 +144,13 @@ HRESULT Direct3DRMMeshImpl::SetGroupMaterial(D3DRMGROUPINDEX groupIndex, IDirect
return DDERR_INVALIDPARAMS;
}
material->AddRef();
auto& group = m_groups[groupIndex];
if (group.material) {
group.material->Release();
}
material->AddRef();
m_groups[groupIndex].material = material;
return DD_OK;
}
@ -170,15 +161,13 @@ HRESULT Direct3DRMMeshImpl::SetGroupTexture(D3DRMGROUPINDEX groupIndex, IDirect3
return DDERR_INVALIDPARAMS;
}
texture->AddRef();
auto& group = m_groups[groupIndex];
if (group.texture) {
group.texture->Release();
}
texture->AddRef();
if (group.texture) {
group.texture->Release();
}
group.texture = texture;
group.version++;
return DD_OK;

View File

@ -232,13 +232,14 @@ HRESULT DirectDrawSurfaceImpl::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
m_texture->Changed(FALSE, TRUE);
}
lpDDPalette->AddRef();
if (m_palette) {
m_palette->Release();
}
m_palette = lpDDPalette;
SDL_SetSurfacePalette(m_surface, ((DirectDrawPaletteImpl*) m_palette)->m_palette);
m_palette->AddRef();
return DD_OK;
}

View File

@ -214,13 +214,14 @@ HRESULT FrameBufferImpl::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
MINIWIN_NOT_IMPLEMENTED();
}
lpDDPalette->AddRef();
if (m_palette) {
m_palette->Release();
}
m_palette = lpDDPalette;
SDL_SetSurfacePalette(m_transferBuffer->m_surface, ((DirectDrawPaletteImpl*) m_palette)->m_palette);
m_palette->AddRef();
return DD_OK;
}

View File

@ -21,8 +21,8 @@ struct Direct3DRMObjectBaseImpl : public T {
it->first(this, it->second);
}
m_callbacks.clear();
SDL_free(m_name);
}
SDL_free(m_name);
return this->T::Release();
}
HRESULT AddDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override