From b4b4d59a88f7e4e022eede985ec0bc48bcab6892 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 6 Aug 2023 00:18:31 -0500 Subject: [PATCH] Fixed memory leak when closing down windows. --- FiestaOnlineEditor/FiestaOnlineEditor.cpp | 1 + FiestaOnlineEditor/ItemEditor.cpp | 2 ++ FiestaOnlineEditor/ItemEditor.h | 1 + FiestaOnlineEditor/Window.cpp | 2 ++ FiestaOnlineEditor/Window.h | 1 + 5 files changed, 7 insertions(+) diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.cpp b/FiestaOnlineEditor/FiestaOnlineEditor.cpp index 8bb5da7..e645d31 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.cpp +++ b/FiestaOnlineEditor/FiestaOnlineEditor.cpp @@ -186,6 +186,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ focusErased=true; } w->Cleanup(); + delete w; return true; } else { return false; diff --git a/FiestaOnlineEditor/ItemEditor.cpp b/FiestaOnlineEditor/ItemEditor.cpp index 9f4ff0c..6ccfdf0 100644 --- a/FiestaOnlineEditor/ItemEditor.cpp +++ b/FiestaOnlineEditor/ItemEditor.cpp @@ -3,6 +3,8 @@ ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size) :Window(pge,windowTitle,pos,size){} +ItemEditor::~ItemEditor(){}; + void ItemEditor::Load(std::string basePath){ ItemInfo.Load(basePath+"/ItemInfo.shn"); } diff --git a/FiestaOnlineEditor/ItemEditor.h b/FiestaOnlineEditor/ItemEditor.h index 27feff2..259bf30 100644 --- a/FiestaOnlineEditor/ItemEditor.h +++ b/FiestaOnlineEditor/ItemEditor.h @@ -10,6 +10,7 @@ class ItemEditor:public Window{ vf2d pos={64,64}; public: ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size); + ~ItemEditor(); void Load(std::string basePath); void Refresh(FiestaOnlineEditor*pge)override; void Update(FiestaOnlineEditor*pge,float fElapsedTime)override; diff --git a/FiestaOnlineEditor/Window.cpp b/FiestaOnlineEditor/Window.cpp index 37dad3f..566274a 100644 --- a/FiestaOnlineEditor/Window.cpp +++ b/FiestaOnlineEditor/Window.cpp @@ -10,6 +10,8 @@ Window::Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size //InternalRefresh(pge); } +Window::~Window(){}; + void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){ if(this==focusedWindow){ Update(pge,fElapsedTime); diff --git a/FiestaOnlineEditor/Window.h b/FiestaOnlineEditor/Window.h index c2b7ff6..c2b736c 100644 --- a/FiestaOnlineEditor/Window.h +++ b/FiestaOnlineEditor/Window.h @@ -19,6 +19,7 @@ protected: std::string windowTitle=""; public: Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size); + virtual ~Window(); void InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime); virtual void Update(FiestaOnlineEditor*pge,float fElapsedTime)=0; virtual void Refresh(FiestaOnlineEditor*pge)=0;