Don't spam the user with many dialogs when pasting invalid styles

Just show a single error dialog regardless of the number of styles that
failed to parse.
This commit is contained in:
Thomas Goyne 2013-12-23 06:50:30 -08:00
parent 3c8160f1e3
commit 3d6cbc8c99
1 changed files with 4 additions and 1 deletions

View File

@ -127,6 +127,7 @@ 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) {
auto cb = GetClipboard();
int failed_to_parse = 0;
for (auto tok : agi::Split(cb, '\n')) {
tok = boost::trim_copy(tok);
if (tok.empty()) continue;
@ -136,10 +137,12 @@ void add_styles(Func1 name_checker, Func2 style_adder) {
style_adder(s);
}
catch (...) {
++failed_to_parse;
}
}
if (failed_to_parse)
wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION);
}
}
}
int confirm_delete(int n, wxWindow *parent, wxString const& title) {
wxString message = n == 1 ?