* Change wxID_CLOSE to wxID_OK

* Destroy the dialogue when closed
 * Don't delete *sink.

Originally committed to SVN as r4413.
This commit is contained in:
Amar Takhar 2010-06-03 03:07:43 +00:00
parent 2e156b8c4f
commit 2d1bea39cf
2 changed files with 16 additions and 6 deletions

View file

@ -66,7 +66,7 @@ LogWindow::LogWindow(wxWindow *parent)
sizer_text->Add(text_ctrl, 1, wxEXPAND); sizer_text->Add(text_ctrl, 1, wxEXPAND);
wxSizer *sizer_button = new wxBoxSizer(wxHORIZONTAL); 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); wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
@ -86,17 +86,16 @@ LogWindow::~LogWindow() {
delete emit_log; delete emit_log;
} }
LogWindow::EmitLog::EmitLog(wxTextCtrl *t): text_ctrl(t) { LogWindow::EmitLog::EmitLog(wxTextCtrl *t): text_ctrl(t) {
const agi::log::Sink *sink = agi::log::log->GetSink(); const agi::log::Sink *sink = agi::log::log->GetSink();
for (unsigned int i=0; i < sink->size(); i++) { for (unsigned int i=0; i < sink->size(); i++) {
Write((*sink)[i]); Write((*sink)[i]);
} }
delete sink;
} }
void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) { void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) {
#ifndef _WIN32 #ifndef _WIN32
tm tmtime; tm tmtime;
@ -121,13 +120,22 @@ void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) {
sm->func, sm->func,
sm->line, sm->line,
sm->message); sm->message);
#endif
text_ctrl->AppendText(log); text_ctrl->AppendText(log);
} }
#endif
void LogWindow::EmitLog::log(agi::log::SinkMessage *sm) { void LogWindow::EmitLog::log(agi::log::SinkMessage *sm) {
delete text_ctrl;
Write(sm); Write(sm);
} }
void LogWindow::OnClose(wxCloseEvent &WXUNUSED(event)) {
Destroy();
}
BEGIN_EVENT_TABLE(LogWindow, wxDialog)
EVT_CLOSE(LogWindow::OnClose)
END_EVENT_TABLE()

View file

@ -65,7 +65,9 @@ public:
LogWindow(wxWindow *parent); LogWindow(wxWindow *parent);
~LogWindow(); ~LogWindow();
DECLARE_EVENT_TABLE()
private: private:
EmitLog *emit_log; void OnClose(wxCloseEvent &event);
EmitLog *emit_log;
}; };