From 3a105f0728984df7f063110acc8390c93722d581 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 1 Jan 2019 13:12:39 -0800 Subject: [PATCH] Catch boost::locale character-conversion exceptions. Partial cause of the crash reported in Bug 797002. --- .../csv-imp/assistant-csv-trans-import.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp index e460d3c3a5..777caf4f01 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp +++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp @@ -2065,9 +2065,22 @@ CsvImpTransAssist::assist_summary_page_prepare () gen.add_messages_domain(GETTEXT_PACKAGE); auto text = std::string(""); + try + { /* Translators: {1} will be replaced with a filename */ - text += (bl::format (bl::translate ("The transactions were imported from file '{1}'.")) % m_file_name).str(gen("")); - text += ""; + text += (bl::format (bl::translate ("The transactions were imported from file '{1}'.")) % m_file_name).str(gen("")); + text += ""; + } + catch (const bl::conv::conversion_error& err) + { + PERR("Transcoding error: %s", err.what()); + text += "The transactions were imported from the file."; + } + catch (const bl::conv::invalid_charset_error& err) + { + PERR("Invalid charset error: %s", err.what()); + text += "The transactions were imported from the file."; + } gtk_label_set_markup (GTK_LABEL(summary_label), text.c_str()); }