Fix ViewLODList leaks (#623)

* Fix ViewLODList leaks

* Add vector clear

* Fix naming
This commit is contained in:
Christian Semmler 2025-07-18 14:34:23 -07:00 committed by GitHub
parent df84f4d7a5
commit 556b2deef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include "lego1_export.h" #include "lego1_export.h"
#include "legonamedpartlist.h" #include "legonamedpartlist.h"
#include "mxmediapresenter.h" #include "mxmediapresenter.h"
#include "viewmanager/viewlodlist.h"
// VTABLE: LEGO1 0x100d4df0 // VTABLE: LEGO1 0x100d4df0
// SIZE 0x54 // SIZE 0x54
@ -50,10 +51,21 @@ class LegoPartPresenter : public MxMediaPresenter {
MxResult Read(MxDSChunk& p_chunk); MxResult Read(MxDSChunk& p_chunk);
void Store(); void Store();
static void Release()
{
for (auto* lodList : g_lodLists) {
lodList->Release();
}
g_lodLists.clear();
}
private: private:
void Destroy(MxBool p_fromDestructor); void Destroy(MxBool p_fromDestructor);
LegoNamedPartList* m_parts; // 0x50 LegoNamedPartList* m_parts; // 0x50
static vector<ViewLODList*> g_lodLists;
}; };
#endif // LEGOPARTPRESENTER_H #endif // LEGOPARTPRESENTER_H

View File

@ -260,8 +260,12 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
ModelDbPart* part; ModelDbPart* part;
while (cursor.Next(part)) { while (cursor.Next(part)) {
if (GetViewLODListManager()->Lookup(part->m_roiName.GetData()) == NULL && ViewLODList* lodList = GetViewLODListManager()->Lookup(part->m_roiName.GetData());
LoadWorldPart(*part, wdbFile) != SUCCESS) { if (lodList) {
lodList->Release();
}
if (lodList == NULL && LoadWorldPart(*part, wdbFile) != SUCCESS) {
return FAILURE; return FAILURE;
} }
} }

View File

@ -122,6 +122,8 @@ void LegoOmni::Destroy()
m_textureContainer = NULL; m_textureContainer = NULL;
} }
LegoPartPresenter::Release();
if (m_viewLODListManager) { if (m_viewLODListManager) {
delete m_viewLODListManager; delete m_viewLODListManager;
m_viewLODListManager = NULL; m_viewLODListManager = NULL;

View File

@ -22,6 +22,8 @@ MxS32 g_partPresenterConfig1 = 1;
// GLOBAL: LEGO1 0x100f7aa4 // GLOBAL: LEGO1 0x100f7aa4
MxS32 g_partPresenterConfig2 = 100; MxS32 g_partPresenterConfig2 = 100;
vector<ViewLODList*> LegoPartPresenter::g_lodLists;
// FUNCTION: LEGO1 0x1007c990 // FUNCTION: LEGO1 0x1007c990
void LegoPartPresenter::configureLegoPartPresenter(MxS32 p_partPresenterConfig1, MxS32 p_partPresenterConfig2) void LegoPartPresenter::configureLegoPartPresenter(MxS32 p_partPresenterConfig1, MxS32 p_partPresenterConfig2)
{ {
@ -261,6 +263,8 @@ void LegoPartPresenter::Store()
lodCursor.Detach(); lodCursor.Detach();
lodList->PushBack(lod); lodList->PushBack(lod);
} }
g_lodLists.push_back(lodList);
} }
else { else {
lodList->Release(); lodList->Release();