mirror of https://github.com/odrling/Aegisub
Fix crash when pasting styles in the styles manager
This commit is contained in:
parent
106fb663c7
commit
92887b53cf
|
@ -55,11 +55,11 @@
|
||||||
#include <libaegisub/fs.h>
|
#include <libaegisub/fs.h>
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
#include <libaegisub/of_type_adaptor.h>
|
#include <libaegisub/of_type_adaptor.h>
|
||||||
|
#include <libaegisub/split.h>
|
||||||
#include <libaegisub/util.h>
|
#include <libaegisub/util.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/tokenizer.hpp>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <wx/bmpbuttn.h>
|
#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>
|
template<class Func1, class Func2>
|
||||||
void add_styles(Func1 name_checker, Func2 style_adder) {
|
void add_styles(Func1 name_checker, Func2 style_adder) {
|
||||||
boost::char_separator<char> sep("\n");
|
auto cb = GetClipboard();
|
||||||
for (auto tok : boost::tokenizer<boost::char_separator<char>>(GetClipboard(), sep)) {
|
for (auto tok : agi::Split(cb, '\n')) {
|
||||||
boost::trim(tok);
|
tok = boost::trim_copy(tok);
|
||||||
|
if (tok.empty()) continue;
|
||||||
try {
|
try {
|
||||||
AssStyle *s = new AssStyle(tok);
|
AssStyle *s = new AssStyle(agi::str(tok));
|
||||||
s->name = unique_name(name_checker, s->name);
|
s->name = unique_name(name_checker, s->name);
|
||||||
style_adder(s);
|
style_adder(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue