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>
@@ -1846,18 +1844,8 @@ void CSettings::DestroyGUI()
18461844 return ;
18471845 }
18481846
1849- CEGUI::Window* pRootWindow = nullptr ;
1850- if (CGUIElement_Impl* pWindowImpl = dynamic_cast <CGUIElement_Impl*>(m_pWindow))
1851- pRootWindow = pWindowImpl->GetWindow ();
1852- if (pRootWindow)
1853- {
1854- // Bottom-up pass that mirrors the CEGUI tree ownership.
1855- DestroyGuiWindowRecursive (pRootWindow);
1856- }
1857- else
1858- {
1859- SAFE_DELETE (m_pWindow);
1860- }
1847+ g_pCore->GetGUI ()->DestroyElementRecursive (m_pWindow);
1848+ m_pWindow = nullptr ;
18611849
18621850 RemoveAllKeyBindSections ();
18631851 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