Fix crash when pasting styles in the styles manager

This commit is contained in:
Thomas Goyne 2013-08-08 20:36:12 -07:00
parent 106fb663c7
commit 92887b53cf
1 changed files with 6 additions and 5 deletions

View File

@ -55,11 +55,11 @@
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/of_type_adaptor.h>
#include <libaegisub/split.h>
#include <libaegisub/util.h>
#include <algorithm>
#include <boost/algorithm/string/trim.hpp>
#include <boost/tokenizer.hpp>
#include <functional>
#include <wx/bmpbuttn.h>
@ -126,11 +126,12 @@ std::string unique_name(Func name_checker, std::string const& source_name) {
template<class Func1, class Func2>
void add_styles(Func1 name_checker, Func2 style_adder) {
boost::char_separator<char> sep("\n");
for (auto tok : boost::tokenizer<boost::char_separator<char>>(GetClipboard(), sep)) {
boost::trim(tok);
auto cb = GetClipboard();
for (auto tok : agi::Split(cb, '\n')) {
tok = boost::trim_copy(tok);
if (tok.empty()) continue;
try {
AssStyle *s = new AssStyle(tok);
AssStyle *s = new AssStyle(agi::str(tok));
s->name = unique_name(name_checker, s->name);
style_adder(s);
}