From 41be900efaed3f916534914746b0b95d2049e30f Mon Sep 17 00:00:00 2001 From: harukalover Date: Sun, 21 Feb 2010 06:09:28 +0000 Subject: [PATCH] Fixed a memory leak that occurred whenever the Edit menu was opened due to the Undo/Redo items being replaced with new wxMenuItem's without deleting the previous items (now it just updates the label/enabled status without creating new wxMenuItem's) Originally committed to SVN as r4139. --- aegisub/src/frame_main_events.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aegisub/src/frame_main_events.cpp b/aegisub/src/frame_main_events.cpp index e1d20257f..d7ec12746 100644 --- a/aegisub/src/frame_main_events.cpp +++ b/aegisub/src/frame_main_events.cpp @@ -432,14 +432,17 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Edit menu else if (curMenu == editMenu) { // Undo state - editMenu->Remove(Menu_Edit_Undo); - editMenu->Remove(Menu_Edit_Redo); - + wxMenuItem *item; wxString undo_text = _("&Undo") + wxString(_T(" ")) + AssFile::GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")); - AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, undo_text, _("Undoes last action"),GETIMAGE(undo_button_16),0)->Enable(!AssFile::IsUndoStackEmpty()); + item = editMenu->FindItem(Menu_Edit_Undo); + item->SetItemLabel(undo_text); + item->Enable(!AssFile::IsUndoStackEmpty()); + // Redo state wxString redo_text = _("&Redo") + wxString(_T(" ")) + AssFile::GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")); - AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, redo_text, _("Redoes last action"),GETIMAGE(redo_button_16),1)->Enable(!AssFile::IsRedoStackEmpty()); + item = editMenu->FindItem(Menu_Edit_Redo); + item->SetItemLabel(redo_text); + item->Enable(!AssFile::IsRedoStackEmpty()); // Copy/cut/paste wxArrayInt sels = SubsBox->GetSelection();