Pass wxStrings to wxString::Format rather than std::string in LogWindow

Originally committed to SVN as r6247.
This commit is contained in:
Thomas Goyne 2012-01-08 01:36:16 +00:00
parent d148bbbf2a
commit 59ce8bf414
3 changed files with 14 additions and 7 deletions

View file

@ -44,6 +44,8 @@
#include "command.h" #include "command.h"
#include <libaegisub/log.h>
#include "../include/aegisub/context.h" #include "../include/aegisub/context.h"
#include "../main.h" #include "../main.h"

View file

@ -49,6 +49,8 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#endif #endif
#include <libaegisub/log.h>
class EmitLog : public agi::log::Emitter { class EmitLog : public agi::log::Emitter {
wxTextCtrl *text_ctrl; wxTextCtrl *text_ctrl;
public: public:
@ -73,7 +75,7 @@ public:
sm->file, sm->file,
sm->func, sm->func,
sm->line, sm->line,
std::string(sm->message, sm->len)); wxString::FromUTF8(sm->message, sm->len));
#else #else
wxString log = wxString::Format("%c %-6ld <%-25s> [%s:%s:%d] %s\n", wxString log = wxString::Format("%c %-6ld <%-25s> [%s:%s:%d] %s\n",
agi::log::Severity_ID[sm->severity], agi::log::Severity_ID[sm->severity],
@ -82,7 +84,7 @@ public:
sm->file, sm->file,
sm->func, sm->func,
sm->line, sm->line,
std::string(sm->message, sm->len)); wxString::FromUTF8(sm->message, sm->len));
#endif #endif
text_ctrl->AppendText(log); text_ctrl->AppendText(log);
} }
@ -99,8 +101,11 @@ LogWindow::LogWindow(wxWindow *parent)
sizer->Add(new wxButton(this, wxID_OK), wxSizerFlags(0).Border().Right()); sizer->Add(new wxButton(this, wxID_OK), wxSizerFlags(0).Border().Right());
SetSizerAndFit(sizer); SetSizerAndFit(sizer);
emit_log.reset(new EmitLog(text_ctrl)); agi::log::log->Subscribe(emit_log = new EmitLog(text_ctrl));
emit_log->Enable();
Bind(wxEVT_CLOSE_WINDOW, std::tr1::bind(&wxDialog::Destroy, this)); Bind(wxEVT_CLOSE_WINDOW, std::tr1::bind(&wxDialog::Destroy, this));
} }
LogWindow::~LogWindow() {
agi::log::log->Unsubscribe(emit_log);
}

View file

@ -38,14 +38,14 @@
#include <wx/dialog.h> #include <wx/dialog.h>
#endif #endif
#include <libaegisub/log.h> namespace agi { namespace log { class Emitter; } }
#include <libaegisub/scoped_ptr.h>
class LogWindow: public wxDialog { class LogWindow: public wxDialog {
agi::scoped_ptr<agi::log::Emitter> emit_log; agi::log::Emitter *emit_log;
public: public:
/// @brief Constructor /// @brief Constructor
/// @param parent Parent frame. /// @param parent Parent frame.
LogWindow(wxWindow *parent); LogWindow(wxWindow *parent);
~LogWindow();
}; };