mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 02:21:15 +00:00
Fix ViewLODList leaks (#623)
* Fix ViewLODList leaks * Add vector clear * Fix naming
This commit is contained in:
parent
df84f4d7a5
commit
556b2deef2
@ -4,6 +4,7 @@
|
||||
#include "lego1_export.h"
|
||||
#include "legonamedpartlist.h"
|
||||
#include "mxmediapresenter.h"
|
||||
#include "viewmanager/viewlodlist.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100d4df0
|
||||
// SIZE 0x54
|
||||
@ -50,10 +51,21 @@ class LegoPartPresenter : public MxMediaPresenter {
|
||||
MxResult Read(MxDSChunk& p_chunk);
|
||||
void Store();
|
||||
|
||||
static void Release()
|
||||
{
|
||||
for (auto* lodList : g_lodLists) {
|
||||
lodList->Release();
|
||||
}
|
||||
|
||||
g_lodLists.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
void Destroy(MxBool p_fromDestructor);
|
||||
|
||||
LegoNamedPartList* m_parts; // 0x50
|
||||
|
||||
static vector<ViewLODList*> g_lodLists;
|
||||
};
|
||||
|
||||
#endif // LEGOPARTPRESENTER_H
|
||||
|
||||
@ -260,8 +260,12 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
|
||||
ModelDbPart* part;
|
||||
|
||||
while (cursor.Next(part)) {
|
||||
if (GetViewLODListManager()->Lookup(part->m_roiName.GetData()) == NULL &&
|
||||
LoadWorldPart(*part, wdbFile) != SUCCESS) {
|
||||
ViewLODList* lodList = GetViewLODListManager()->Lookup(part->m_roiName.GetData());
|
||||
if (lodList) {
|
||||
lodList->Release();
|
||||
}
|
||||
|
||||
if (lodList == NULL && LoadWorldPart(*part, wdbFile) != SUCCESS) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +122,8 @@ void LegoOmni::Destroy()
|
||||
m_textureContainer = NULL;
|
||||
}
|
||||
|
||||
LegoPartPresenter::Release();
|
||||
|
||||
if (m_viewLODListManager) {
|
||||
delete m_viewLODListManager;
|
||||
m_viewLODListManager = NULL;
|
||||
|
||||
@ -22,6 +22,8 @@ MxS32 g_partPresenterConfig1 = 1;
|
||||
// GLOBAL: LEGO1 0x100f7aa4
|
||||
MxS32 g_partPresenterConfig2 = 100;
|
||||
|
||||
vector<ViewLODList*> LegoPartPresenter::g_lodLists;
|
||||
|
||||
// FUNCTION: LEGO1 0x1007c990
|
||||
void LegoPartPresenter::configureLegoPartPresenter(MxS32 p_partPresenterConfig1, MxS32 p_partPresenterConfig2)
|
||||
{
|
||||
@ -261,6 +263,8 @@ void LegoPartPresenter::Store()
|
||||
lodCursor.Detach();
|
||||
lodList->PushBack(lod);
|
||||
}
|
||||
|
||||
g_lodLists.push_back(lodList);
|
||||
}
|
||||
else {
|
||||
lodList->Release();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user