Skip to content

Commit

Permalink
DolphinWX: Fix memory leaks relating to the TAS dialog
Browse files Browse the repository at this point in the history
Initially, the dialogs construct in the background when Dolphin initializes. However, it waits until the user actually makes the dialogs visible to decide on whether to create the Wii or GC control layouts.

Therefore, the call to CreateBaseLayout() essentially creates a sizer that isn't actually attached to a main sizer that is set as the sizer for the dialog to use. So upon destruction, these controls would never actually be destroyed if the user didn't open and then close the TAS dialogs.
  • Loading branch information
lioncash committed Apr 10, 2015
1 parent 1a18cad commit 00943b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Source/Core/DolphinWX/TASInputDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ TASInputDlg::TASInputDlg(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateBaseLayout();
}

void TASInputDlg::CreateBaseLayout()
Expand All @@ -63,6 +62,7 @@ void TASInputDlg::CreateBaseLayout()
m_dpad_down = CreateButton("Down");
m_dpad_left = CreateButton("Left");

m_buttons_dpad = new wxGridSizer(3);
m_buttons_dpad->AddSpacer(20);
m_buttons_dpad->Add(m_dpad_up.checkbox);
m_buttons_dpad->AddSpacer(20);
Expand Down Expand Up @@ -93,6 +93,8 @@ void TASInputDlg::CreateWiiLayout(int num)
if (m_has_layout)
return;

CreateBaseLayout();

m_buttons[6] = &m_one;
m_buttons[7] = &m_two;
m_buttons[8] = &m_plus;
Expand Down Expand Up @@ -196,6 +198,8 @@ void TASInputDlg::CreateGCLayout()
if (m_has_layout)
return;

CreateBaseLayout();

m_buttons[6] = &m_x;
m_buttons[7] = &m_y;
m_buttons[8] = &m_z;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/TASInputDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ class TASInputDlg : public wxDialog

bool m_has_layout = false;

wxGridSizer* const m_buttons_dpad = new wxGridSizer(3);
wxGridSizer* m_buttons_dpad;
};

0 comments on commit 00943b1

Please sign in to comment.