Fix crash when clearing the contents of one of the Margin boxes

This commit is contained in:
Thomas Goyne 2013-04-07 08:40:24 -07:00
parent d3cfa20db9
commit e5c25fa066
1 changed files with 3 additions and 4 deletions

View File

@ -58,7 +58,6 @@
#include <libaegisub/dispatch.h> #include <libaegisub/dispatch.h>
#include <libaegisub/of_type_adaptor.h> #include <libaegisub/of_type_adaptor.h>
#include <boost/lexical_cast.hpp>
#include <functional> #include <functional>
#include <unordered_set> #include <unordered_set>
@ -234,9 +233,9 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS
middle_left_sizer->Add(ctrl, wxSizerFlags().Center()); middle_left_sizer->Add(ctrl, wxSizerFlags().Center());
Bind(wxEVT_COMMAND_TEXT_UPDATED, [=](wxCommandEvent&) { Bind(wxEVT_COMMAND_TEXT_UPDATED, [=](wxCommandEvent&) {
int value = mid(0, boost::lexical_cast<int>(from_wx(ctrl->GetValue())), 9999); int value = mid(0, atoi(ctrl->GetValue().utf8_str()), 9999);
SetSelectedRows([&](AssDialogue *d) { d->Margin[margin] = value; }, commit_msg, AssFile::COMMIT_DIAG_META); SetSelectedRows([&](AssDialogue *d) { d->Margin[margin] = value; },
if (line) change_value(ctrl, to_wx(line->GetMarginString(margin))); commit_msg, AssFile::COMMIT_DIAG_META);
}, ctrl->GetId()); }, ctrl->GetId());
return ctrl; return ctrl;