From ced315f677e6deae4d371ae581be79d37b8881be Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Fri, 17 Jun 2011 09:19:13 +0000 Subject: [PATCH] Properly destroy cheat manager window when closed. Fixes issue 4595. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7604 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/CheatsWindow.cpp | 24 ++++++++++++++++++---- Source/Core/DolphinWX/Src/CheatsWindow.h | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinWX/Src/CheatsWindow.cpp b/Source/Core/DolphinWX/Src/CheatsWindow.cpp index 2e08e510bd..3a2a414b4b 100644 --- a/Source/Core/DolphinWX/Src/CheatsWindow.cpp +++ b/Source/Core/DolphinWX/Src/CheatsWindow.cpp @@ -64,6 +64,7 @@ wxCheatsWindow::wxCheatsWindow(wxWindow* const parent) wxCheatsWindow::~wxCheatsWindow() { main_frame->g_CheatsWindow = NULL; + ::g_cheat_window = NULL; } void wxCheatsWindow::Init_ChildControls() @@ -135,6 +136,9 @@ void wxCheatsWindow::Init_ChildControls() _connect_macro_(button_apply, wxCheatsWindow::OnEvent_ApplyChanges_Press, wxEVT_COMMAND_BUTTON_CLICKED, this); wxButton* const button_cancel = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize); _connect_macro_(button_cancel, wxCheatsWindow::OnEvent_ButtonClose_Press, wxEVT_COMMAND_BUTTON_CLICKED, this); + + Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(wxCheatsWindow::OnEvent_Close), (wxObject*)0, this); + wxStdDialogButtonSizer* const sButtons = new wxStdDialogButtonSizer(); sButtons->AddButton(button_apply); sButtons->AddButton(button_cancel); @@ -248,9 +252,14 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) SetSizerAndFit(sizer_main); } -void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& ev) +void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event)) { - ev.Skip(); + Close(); +} + +void wxCheatsWindow::OnEvent_Close(wxCloseEvent& ev) +{ + Destroy(); } void wxCheatsWindow::Load_ARCodes() @@ -578,8 +587,10 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) sizer_main->Add(sizer_value_label, 0, wxALL, 5); sizer_main->Add(textctrl_value, 0, wxALL, 5); sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxALL, 5); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CreateCodeDialog::PressOK)); Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CreateCodeDialog::PressCancel)); + Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CreateCodeDialog::OnEvent_Close), (wxObject*)0, this); SetSizerAndFit(sizer_main); SetFocus(); @@ -626,10 +637,15 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) // refresh arcode list in other tab ::g_cheat_window->Load_ARCodes(); - ev.Skip(); + Close(); } void CreateCodeDialog::PressCancel(wxCommandEvent& ev) { - ev.Skip(); + Close(); +} + +void CreateCodeDialog::OnEvent_Close(wxCloseEvent& ev) +{ + Destroy(); } diff --git a/Source/Core/DolphinWX/Src/CheatsWindow.h b/Source/Core/DolphinWX/Src/CheatsWindow.h index 35a2d0883c..9d44e878f3 100644 --- a/Source/Core/DolphinWX/Src/CheatsWindow.h +++ b/Source/Core/DolphinWX/Src/CheatsWindow.h @@ -55,6 +55,7 @@ protected: void PressOK(wxCommandEvent&); void PressCancel(wxCommandEvent&); + void OnEvent_Close(wxCloseEvent& ev); }; class CheatSearchTab : public wxPanel @@ -151,6 +152,7 @@ class wxCheatsWindow : public wxDialog // $ Close Button void OnEvent_ButtonClose_Press(wxCommandEvent& event); + void OnEvent_Close(wxCloseEvent& ev); // $ Cheats List void OnEvent_CheatsList_ItemSelected(wxCommandEvent& event);