Fixed memory leak when closing down windows.

This commit is contained in:
sigonasr2 2023-08-06 00:18:31 -05:00
parent cb4a564c48
commit b4b4d59a88
5 changed files with 7 additions and 0 deletions

View File

@ -186,6 +186,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
focusErased=true; focusErased=true;
} }
w->Cleanup(); w->Cleanup();
delete w;
return true; return true;
} else { } else {
return false; return false;

View File

@ -3,6 +3,8 @@
ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size) ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size)
:Window(pge,windowTitle,pos,size){} :Window(pge,windowTitle,pos,size){}
ItemEditor::~ItemEditor(){};
void ItemEditor::Load(std::string basePath){ void ItemEditor::Load(std::string basePath){
ItemInfo.Load(basePath+"/ItemInfo.shn"); ItemInfo.Load(basePath+"/ItemInfo.shn");
} }

View File

@ -10,6 +10,7 @@ class ItemEditor:public Window{
vf2d pos={64,64}; vf2d pos={64,64};
public: public:
ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size); ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size);
~ItemEditor();
void Load(std::string basePath); void Load(std::string basePath);
void Refresh(FiestaOnlineEditor*pge)override; void Refresh(FiestaOnlineEditor*pge)override;
void Update(FiestaOnlineEditor*pge,float fElapsedTime)override; void Update(FiestaOnlineEditor*pge,float fElapsedTime)override;

View File

@ -10,6 +10,8 @@ Window::Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size
//InternalRefresh(pge); //InternalRefresh(pge);
} }
Window::~Window(){};
void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){ void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){
if(this==focusedWindow){ if(this==focusedWindow){
Update(pge,fElapsedTime); Update(pge,fElapsedTime);

View File

@ -19,6 +19,7 @@ protected:
std::string windowTitle=""; std::string windowTitle="";
public: public:
Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size); Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size);
virtual ~Window();
void InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime); void InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime);
virtual void Update(FiestaOnlineEditor*pge,float fElapsedTime)=0; virtual void Update(FiestaOnlineEditor*pge,float fElapsedTime)=0;
virtual void Refresh(FiestaOnlineEditor*pge)=0; virtual void Refresh(FiestaOnlineEditor*pge)=0;