From 5253c7eb8b39a82d0232828b7b1cff4c5622ce0a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 31 Mar 2020 18:26:54 +0200 Subject: [PATCH] Tweak error-dump (when session load fails) When limiting the message count (e.g. for display in a dialog), use reverse order, and only print errors. When loading a session fails, the most recent error is more likely the real cause. --- libs/gtkmm2ext/gtk_ui.cc | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index e38ba71d45..067f712198 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -514,16 +514,40 @@ void UI::dump_errors (std::ostream& ostr, size_t limit) { Glib::Threads::Mutex::Lock lm (error_lock); - ostr << endl << X_("Errors/Messages:") << endl; - for (list::const_iterator i = error_stack.begin(); i != error_stack.end(); ++i) { - ostr << *i << endl; - if (limit > 0) { + bool first = true; + + if (limit > 0) { + /* reverse listing, Errors only */ + for (list::const_reverse_iterator i = error_stack.rbegin(); i != error_stack.rend(); ++i) { + if ((*i).substr (0, 9) == X_("WARNING: ") || (*i).substr (0, 6) == X_("INFO: ")) { + continue; + } + if (first) { + first = false; + } + ostr << *i << endl; if (--limit == 0) { ostr << "..." << endl; break; } } } + + if (first) { + for (list::const_iterator i = error_stack.begin(); i != error_stack.end(); ++i) { + if (first) { + ostr << endl << X_("Log Messages:") << endl; + first = false; + } + ostr << *i << endl; + if (limit > 0) { + if (--limit == 0) { + ostr << "..." << endl; + break; + } + } + } + } ostr << endl; }