From e05f939fab6f31307ecc32e0daef099a6ade7ca8 Mon Sep 17 00:00:00 2001 From: elexis Date: Fri, 20 Sep 2019 15:25:13 +0000 Subject: [PATCH] Delete empty IGUIObject::Destroy function and MEGA TODO from 5122b0f906, e21ebb37f5. None of the GUI object types implemented in the past two decades owns children, only the CGUI page. Differential Revision: https://code.wildfiregames.com/D2311 Tested on: clang 8.0.1, Jenkins This was SVN commit r22943. --- source/gui/CGUI.cpp | 33 +++++---------------------------- source/gui/CGUI.h | 6 ------ source/gui/IGUIObject.cpp | 5 ----- source/gui/IGUIObject.h | 6 ------ 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 74d72b6dc1..91fadae3c6 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -296,7 +296,11 @@ CGUI::CGUI(const shared_ptr& runtime) CGUI::~CGUI() { - Destroy(); + for (const std::pair& p : m_pAllObjects) + delete p.second; + + for (const std::pair& p : m_Sprites) + delete p.second; } IGUIObject* CGUI::ConstructObject(const CStr& str) @@ -357,33 +361,6 @@ void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Sprite.Draw(*this, Rect, CellID, m_Sprites, Z); } -void CGUI::Destroy() -{ - // We can use the map to delete all - // now we don't want to cancel all if one Destroy fails - for (const std::pair& p : m_pAllObjects) - { - try - { - p.second->Destroy(); - } - catch (PSERROR_GUI& e) - { - UNUSED2(e); - debug_warn(L"CGUI::Destroy error"); - // TODO Gee: Handle - } - - delete p.second; - } - m_pAllObjects.clear(); - - for (const std::pair& p : m_Sprites) - delete p.second; - m_Sprites.clear(); - m_Icons.clear(); -} - void CGUI::UpdateResolution() { // Update ALL cached diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index 9000543f8d..14acb4425a 100644 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -122,12 +122,6 @@ public: */ void DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Z, const CRect& Rect, const CRect& Clipping = CRect()); - /** - * Clean up, call this to clean up all memory allocated - * within the GUI. - */ - void Destroy(); - /** * The replacement of Process(), handles an SDL_Event_ * diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index e232298802..fda54034a2 100644 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -113,11 +113,6 @@ void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) } } -void IGUIObject::Destroy() -{ - // Is there anything besides the children to destroy? -} - template void IGUIObject::AddSetting(const CStr& Name) { diff --git a/source/gui/IGUIObject.h b/source/gui/IGUIObject.h index d11ba3464c..a9ebc5cfe0 100644 --- a/source/gui/IGUIObject.h +++ b/source/gui/IGUIObject.h @@ -243,12 +243,6 @@ protected: */ template void AddSetting(const CStr& Name); - /** - * Calls Destroy on all children, and deallocates all memory. - * MEGA TODO Should it destroy it's children? - */ - virtual void Destroy(); - public: /** * This function is called with different messages