File tree Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Original file line number Diff line number Diff line change 1212#include " StdInc.h"
1313#include < algorithm>
1414#include < vector>
15- #include " ../gui/GuiCleanup.h"
16- #include " ../gui/CGUIElement_Impl.h"
1715#include < core/CClientCommands.h>
1816#include < game/CGame.h>
1917#include < game/CSettings.h>
@@ -1837,18 +1835,8 @@ void CSettings::DestroyGUI()
18371835 return ;
18381836 }
18391837
1840- CEGUI::Window* pRootWindow = nullptr ;
1841- if (CGUIElement_Impl* pWindowImpl = dynamic_cast <CGUIElement_Impl*>(m_pWindow))
1842- pRootWindow = pWindowImpl->GetWindow ();
1843- if (pRootWindow)
1844- {
1845- // Bottom-up pass that mirrors the CEGUI tree ownership.
1846- DestroyGuiWindowRecursive (pRootWindow);
1847- }
1848- else
1849- {
1850- SAFE_DELETE (m_pWindow);
1851- }
1838+ g_pCore->GetGUI ()->DestroyElementRecursive (m_pWindow);
1839+ m_pWindow = nullptr ;
18521840
18531841 RemoveAllKeyBindSections ();
18541842 m_bBrowserListsChanged = false ;
Original file line number Diff line number Diff line change 1515
1616using std::list;
1717
18- void CGUI_Impl::DestroyWindowRecursive (CEGUI::Window* pWindow )
18+ void CGUI_Impl::DestroyElementRecursive (CGUIElement* pElement )
1919{
20- DestroyGuiWindowRecursive (pWindow);
20+ if (!pElement)
21+ return ;
22+
23+ if (auto * pImpl = dynamic_cast <CGUIElement_Impl*>(pElement))
24+ {
25+ DestroyGuiWindowRecursive (pImpl->GetWindow ());
26+ return ;
27+ }
28+
29+ delete pElement;
2130}
2231
2332#define CGUI_MTA_DEFAULT_FONT " tahoma.ttf" // %WINDIR%/font/<...>
Original file line number Diff line number Diff line change @@ -83,8 +83,6 @@ class CGUI_Impl : public CGUI, public CGUITabList
8383 static CEGUI::String GetUTFString (const char * szInput);
8484 static CEGUI::String GetUTFString (const std::string& strInput);
8585 static CEGUI::String GetUTFString (const CEGUI::String& strInput); // Not defined
86- static void DestroyWindowRecursive (CEGUI::Window* pWindow);
87-
8886 //
8987 CGUIMessageBox* CreateMessageBox (const char * szTitle, const char * szMessage, unsigned int uiFlags);
9088
@@ -277,6 +275,7 @@ class CGUI_Impl : public CGUI, public CGUITabList
277275 void RemoveFromRedrawQueue (CGUIElement* pWindow);
278276
279277 void CleanDeadPool ();
278+ void DestroyElementRecursive (CGUIElement* pElement);
280279 CGUIWindow* LoadLayout (CGUIElement* pParent, const SString& strFilename);
281280 bool LoadImageset (const SString& strFilename);
282281
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ class CGUI
166166 virtual void ClearSystemKeys () = 0;
167167
168168 virtual void CleanDeadPool () = 0;
169+ virtual void DestroyElementRecursive (CGUIElement* pElement) = 0;
169170
170171 virtual CGUIWindow* LoadLayout (CGUIElement* pParent, const SString& strFilename) = 0;
171172 virtual bool LoadImageset (const SString& strFilename) = 0;
You can’t perform that action at this time.
0 commit comments