From 2d1bea39cfa7122635ba08a11f90b4094c34aed2 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Thu, 3 Jun 2010 03:07:43 +0000 Subject: [PATCH] * Change wxID_CLOSE to wxID_OK * Destroy the dialogue when closed * Don't delete *sink. Originally committed to SVN as r4413. --- aegisub/src/dialog_log.cpp | 18 +++++++++++++----- aegisub/src/dialog_log.h | 4 +++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/aegisub/src/dialog_log.cpp b/aegisub/src/dialog_log.cpp index d84075641..5aa6ddfa1 100644 --- a/aegisub/src/dialog_log.cpp +++ b/aegisub/src/dialog_log.cpp @@ -66,7 +66,7 @@ LogWindow::LogWindow(wxWindow *parent) sizer_text->Add(text_ctrl, 1, wxEXPAND); wxSizer *sizer_button = new wxBoxSizer(wxHORIZONTAL); - sizer_button->Add(new wxButton(this, wxID_CLOSE), 0, wxALIGN_RIGHT | wxALL, 2); + sizer_button->Add(new wxButton(this, wxID_OK), 0, wxALIGN_RIGHT | wxALL, 2); wxSizer *sizer = new wxBoxSizer(wxVERTICAL); @@ -86,17 +86,16 @@ LogWindow::~LogWindow() { delete emit_log; } + LogWindow::EmitLog::EmitLog(wxTextCtrl *t): text_ctrl(t) { const agi::log::Sink *sink = agi::log::log->GetSink(); for (unsigned int i=0; i < sink->size(); i++) { Write((*sink)[i]); } - delete sink; } - void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) { #ifndef _WIN32 tm tmtime; @@ -121,13 +120,22 @@ void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) { sm->func, sm->line, sm->message); - +#endif text_ctrl->AppendText(log); } -#endif + void LogWindow::EmitLog::log(agi::log::SinkMessage *sm) { + delete text_ctrl; Write(sm); } +void LogWindow::OnClose(wxCloseEvent &WXUNUSED(event)) { + Destroy(); +} + + +BEGIN_EVENT_TABLE(LogWindow, wxDialog) + EVT_CLOSE(LogWindow::OnClose) +END_EVENT_TABLE() diff --git a/aegisub/src/dialog_log.h b/aegisub/src/dialog_log.h index a39aaad55..d31881292 100644 --- a/aegisub/src/dialog_log.h +++ b/aegisub/src/dialog_log.h @@ -65,7 +65,9 @@ public: LogWindow(wxWindow *parent); ~LogWindow(); + DECLARE_EVENT_TABLE() private: - EmitLog *emit_log; + void OnClose(wxCloseEvent &event); + EmitLog *emit_log; };