From 9d421e1666bf2ad73e288d6b262db42fcb419397 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 23 Dec 2013 06:50:30 -0800 Subject: [PATCH] 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. --- aegisub/src/dialog_style_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 1e1f6f906..0b466dba9 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -127,6 +127,7 @@ std::string unique_name(Func name_checker, std::string const& source_name) { template 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,9 +137,11 @@ void add_styles(Func1 name_checker, Func2 style_adder) { style_adder(s); } catch (...) { - wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION); + ++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) {