Skip to content

Commit d04a8ec

Browse files
committed
Addendum #2 to f2e93f2
1 parent 67a7a63 commit d04a8ec

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

Client/core/CSettings.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
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;

Client/gui/CGUI_Impl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@
1515

1616
using 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/<...>

Client/gui/CGUI_Impl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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

Client/sdk/gui/CGUI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)