Skip to content

Commit 1c406d1

Browse files
committed
Mark GUIControl destructor as virtual
Previously GUIControl destructor was not virtual and did not run any of derived classes destructors. Now that it is and derived destructors are ran, they actually double free due to `Destroy` has already been called on the objects by `GUIControlManager::Clear`. They were also inconsistent with some classes having them and some not, so I unified the approach and removed the destructors in `GUIControl`-derived classes that only called `Destroy`.
1 parent 22c1aa5 commit 1c406d1

File tree

7 files changed

+2
-22
lines changed

7 files changed

+2
-22
lines changed

Source/GUI/GUICollectionBox.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ GUICollectionBox::GUICollectionBox(GUIManager* Manager, GUIControlManager* Contr
1616
m_IsContainer = true; // We are a container
1717
}
1818

19-
GUICollectionBox::~GUICollectionBox() {
20-
Destroy();
21-
}
22-
2319
void GUICollectionBox::Create(const std::string& Name, int X, int Y, int Width, int Height) {
2420
GUIControl::Create(Name, X, Y, Width, Height);
2521

Source/GUI/GUICollectionBox.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ namespace RTE {
2424
/// @param Manager GUIManager, GUIControlManager.
2525
GUICollectionBox(GUIManager* Manager, GUIControlManager* ControlManager);
2626

27-
/// Destructor method used to clean up this before deletion from memory.
28-
~GUICollectionBox();
29-
3027
/// Called when the control has been created.
3128
/// @param Name Name, Position.
3229
void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override;

Source/GUI/GUIControl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace RTE {
2222
/// system memory.
2323
GUIControl();
2424

25+
virtual ~GUIControl() = default;
26+
2527
/// Called when the control has been created.
2628
/// @param Name Name, Position, Size
2729
virtual void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1);

Source/GUI/GUISkin.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ GUISkin::GUISkin(GUIScreen* Screen) {
1717
Clear();
1818
}
1919

20-
GUISkin::~GUISkin() {
21-
Destroy();
22-
}
23-
2420
void GUISkin::Clear() {
2521
m_PropList.clear();
2622
m_ImageCache.clear();

Source/GUI/GUISkin.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ namespace RTE {
1111
/// @param Screen GUIScreen Interface.
1212
explicit GUISkin(GUIScreen* Screen);
1313

14-
/// Destructor method used to free a GUISkin object in system
15-
/// memory.
16-
~GUISkin();
17-
1814
/// Loads a skin for a directory
1915
/// @param directory Skin directory and the file within to use
2016
bool Load(const std::string& directory, const std::string& fileName = "skin.ini");

Source/GUI/GUISound.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ GUISound::GUISound() {
88
Clear();
99
}
1010

11-
GUISound::~GUISound() {
12-
Destroy();
13-
}
14-
1511
void GUISound::Clear() {
1612
m_SplashSound.Reset();
1713
m_EnterMenuSound.Reset();

Source/GUI/GUISound.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ namespace RTE {
2222
#pragma region Destruction
2323
/// Destroys and resets (through Clear()) the GUISound object.
2424
void Destroy() { Clear(); }
25-
26-
/// Destructor method used to clean up a GUISound object before deletion from system memory.
27-
~GUISound();
2825
#pragma endregion
2926

3027
#pragma region Getters

0 commit comments

Comments
 (0)