Skip to content

Commit 8052d64

Browse files
committed
Addendum #2 to f2e93f2
1 parent 6fd9d8b commit 8052d64

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>
@@ -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;

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)