Index: source/gui/CGUI.h =================================================================== --- source/gui/CGUI.h +++ source/gui/CGUI.h @@ -123,12 +123,6 @@ 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_ * * @param ev SDL Event, like mouse/keyboard input Index: source/gui/CGUI.cpp =================================================================== --- source/gui/CGUI.cpp +++ source/gui/CGUI.cpp @@ -359,27 +359,14 @@ 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 - } + SAFE_DELETE(p.second); - delete p.second; - } m_pAllObjects.clear(); for (const std::pair& p : m_Sprites) - delete p.second; + SAFE_DELETE(p.second); + m_Sprites.clear(); m_Icons.clear(); } Index: source/gui/IGUIObject.h =================================================================== --- source/gui/IGUIObject.h +++ source/gui/IGUIObject.h @@ -243,12 +243,6 @@ */ 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 Index: source/gui/IGUIObject.cpp =================================================================== --- source/gui/IGUIObject.cpp +++ source/gui/IGUIObject.cpp @@ -113,11 +113,6 @@ } } -void IGUIObject::Destroy() -{ - // Is there anything besides the children to destroy? -} - template void IGUIObject::AddSetting(const CStr& Name) {