Skip to content

Commit

Permalink
#5532: Remove unmapped pages to prevent resource leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 21, 2021
1 parent fa071ec commit 0b1fbf9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -175,6 +175,22 @@ MaterialEditor::MaterialEditor() :
updateControlsFromMaterial();
}

MaterialEditor::~MaterialEditor()
{
auto notebook = getControl<wxNotebook>("MaterialStageSettingsNotebook");

// Remove all umapped pages to avoid memory leaks
for (const auto& pair : _notebookPages)
{
if (notebook->FindPage(pair.first) == -1)
{
pair.first->Destroy();
}
}

_notebookPages.clear();
}

int MaterialEditor::ShowModal()
{
// Restore the position
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/materials/MaterialEditor.h
Expand Up @@ -82,6 +82,7 @@ class MaterialEditor :

private:
MaterialEditor();
~MaterialEditor();

int ShowModal() override;

Expand Down

0 comments on commit 0b1fbf9

Please sign in to comment.