DolphinWX: Eliminate some memory leaks

Since the menus aren't actually assigned a parent, they would not be freed by wx. Plus, these should have initially been constructed on the stack in the first place.
Technically any time someone right-clicked the game list they would be leaking memory.
This commit is contained in:
Lioncash
2014-11-11 09:50:11 -05:00
parent 71d8165a86
commit 892bbdade6
8 changed files with 104 additions and 104 deletions

View File

@ -364,26 +364,26 @@ void CCodeView::OnMouseUpR(wxMouseEvent& event)
{
bool isSymbol = m_symbol_db->GetSymbolFromAddr(m_selection) != nullptr;
// popup menu
wxMenu* menu = new wxMenu;
wxMenu menu;
//menu->Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
menu->Append(IDM_FOLLOWBRANCH, _("&Follow branch"))->Enable(AddrToBranch(m_selection) ? true : false);
menu->AppendSeparator();
menu.Append(IDM_FOLLOWBRANCH, _("&Follow branch"))->Enable(AddrToBranch(m_selection) ? true : false);
menu.AppendSeparator();
#if wxUSE_CLIPBOARD
menu->Append(IDM_COPYADDRESS, _("Copy &address"));
menu->Append(IDM_COPYFUNCTION, _("Copy &function"))->Enable(isSymbol);
menu->Append(IDM_COPYCODE, _("Copy &code line"));
menu->Append(IDM_COPYHEX, _("Copy &hex"));
menu->AppendSeparator();
menu.Append(IDM_COPYADDRESS, _("Copy &address"));
menu.Append(IDM_COPYFUNCTION, _("Copy &function"))->Enable(isSymbol);
menu.Append(IDM_COPYCODE, _("Copy &code line"));
menu.Append(IDM_COPYHEX, _("Copy &hex"));
menu.AppendSeparator();
#endif
menu->Append(IDM_RENAMESYMBOL, _("Rename &symbol"))->Enable(isSymbol);
menu->AppendSeparator();
menu->Append(IDM_RUNTOHERE, _("&Run To Here"))->Enable(Core::IsRunning());
menu->Append(IDM_ADDFUNCTION, _("&Add function"))->Enable(Core::IsRunning());
menu->Append(IDM_JITRESULTS, _("PPC vs X86"))->Enable(Core::IsRunning());
menu->Append(IDM_INSERTBLR, _("Insert &blr"))->Enable(Core::IsRunning());
menu->Append(IDM_INSERTNOP, _("Insert &nop"))->Enable(Core::IsRunning());
menu->Append(IDM_PATCHALERT, _("Patch alert"))->Enable(Core::IsRunning());
PopupMenu(menu);
menu.Append(IDM_RENAMESYMBOL, _("Rename &symbol"))->Enable(isSymbol);
menu.AppendSeparator();
menu.Append(IDM_RUNTOHERE, _("&Run To Here"))->Enable(Core::IsRunning());
menu.Append(IDM_ADDFUNCTION, _("&Add function"))->Enable(Core::IsRunning());
menu.Append(IDM_JITRESULTS, _("PPC vs X86"))->Enable(Core::IsRunning());
menu.Append(IDM_INSERTBLR, _("Insert &blr"))->Enable(Core::IsRunning());
menu.Append(IDM_INSERTNOP, _("Insert &nop"))->Enable(Core::IsRunning());
menu.Append(IDM_PATCHALERT, _("Patch alert"))->Enable(Core::IsRunning());
PopupMenu(&menu);
event.Skip();
}

View File

@ -221,22 +221,22 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event)
void CMemoryView::OnMouseDownR(wxMouseEvent& event)
{
// popup menu
wxMenu* menu = new wxMenu;
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, _("&Goto in mem view"));
#if wxUSE_CLIPBOARD
menu->Append(IDM_COPYADDRESS, _("Copy &address"));
menu->Append(IDM_COPYHEX, _("Copy &hex"));
menu.Append(IDM_COPYADDRESS, _("Copy &address"));
menu.Append(IDM_COPYHEX, _("Copy &hex"));
#endif
menu->Append(IDM_WATCHADDRESS, _("Add to &watch"));
menu->Append(IDM_TOGGLEMEMORY, _("Toggle &memory"));
menu.Append(IDM_WATCHADDRESS, _("Add to &watch"));
menu.Append(IDM_TOGGLEMEMORY, _("Toggle &memory"));
wxMenu* viewAsSubMenu = new wxMenu;
viewAsSubMenu->Append(IDM_VIEWASFP, _("FP value"));
viewAsSubMenu->Append(IDM_VIEWASASCII, "ASCII");
viewAsSubMenu->Append(IDM_VIEWASHEX, _("Hex"));
menu->AppendSubMenu(viewAsSubMenu, _("View As:"));
wxMenu viewAsSubMenu;
viewAsSubMenu.Append(IDM_VIEWASFP, _("FP value"));
viewAsSubMenu.Append(IDM_VIEWASASCII, "ASCII");
viewAsSubMenu.Append(IDM_VIEWASHEX, _("Hex"));
menu.AppendSubMenu(&viewAsSubMenu, _("View As:"));
PopupMenu(menu);
PopupMenu(&menu);
}
void CMemoryView::OnPaint(wxPaintEvent& event)

View File

@ -274,10 +274,10 @@ void CRegisterView::OnMouseDownR(wxGridEvent& event)
wxString strNewVal = GetValueByRowCol(row, col);
TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress);
wxMenu* menu = new wxMenu;
menu->Append(IDM_WATCHADDRESS, _("Add to &watch"));
menu->Append(IDM_VIEWMEMORY, _("View &memory"));
PopupMenu(menu);
wxMenu menu;
menu.Append(IDM_WATCHADDRESS, _("Add to &watch"));
menu.Append(IDM_VIEWMEMORY, _("View &memory"));
PopupMenu(&menu);
}
void CRegisterView::OnPopupMenu(wxCommandEvent& event)

View File

@ -247,18 +247,18 @@ void CWatchView::OnMouseDownR(wxGridEvent& event)
TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress);
}
wxMenu* menu = new wxMenu;
wxMenu menu;
if (row != 0 && row != (int)(PowerPC::watches.GetWatches().size() + 1))
menu->Append(IDM_DELETEWATCH, _("&Delete watch"));
menu.Append(IDM_DELETEWATCH, _("&Delete watch"));
if (row != 0 && row != (int)(PowerPC::watches.GetWatches().size() + 1) && (col == 1 || col == 2))
{
#ifdef ENABLE_MEM_CHECK
menu->Append(IDM_ADDMEMCHECK, _("Add memory &breakpoint"));
menu.Append(IDM_ADDMEMCHECK, _("Add memory &breakpoint"));
#endif
menu->Append(IDM_VIEWMEMORY, _("View &memory"));
menu.Append(IDM_VIEWMEMORY, _("View &memory"));
}
PopupMenu(menu);
PopupMenu(&menu);
}
void CWatchView::OnPopupMenu(wxCommandEvent& event)