From e9a117b21bda9c9810cff2f543efa9b283d95c08 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 13 Nov 2020 10:58:14 +0100 Subject: [PATCH] Bug 798008 - Option '--log' cannot be specified more than once Wrapping the std::vector to hold the log flags is unneeded and actually harmful. Just work on the vector directly. If user doesn't specify any '--log' options the vector will just be empty. --- gnucash/gnucash-core-app.cpp | 29 +++++++++++++---------------- gnucash/gnucash-core-app.hpp | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gnucash/gnucash-core-app.cpp b/gnucash/gnucash-core-app.cpp index 6a6b6a80de..451b1f712c 100644 --- a/gnucash/gnucash-core-app.cpp +++ b/gnucash/gnucash-core-app.cpp @@ -346,7 +346,7 @@ load_user_config(void) static void -gnc_log_init (const boost::optional > &log_flags, +gnc_log_init (const std::vector log_flags, const boost::optional &log_to_filename) { if (log_to_filename && !log_to_filename->empty()) @@ -389,24 +389,21 @@ gnc_log_init (const boost::optional > &log_flags, qof_log_parse_log_config (log_config_filename); g_free (log_config_filename); - if (log_flags && !log_flags->empty()) + for (auto log_flag : log_flags) { - for (auto log_flag : *log_flags) + if (log_flag.empty () || + log_flag[0] == '=' || + log_flag[log_flag.length () - 1] == '=') { - if (log_flag.empty () || - log_flag[0] == '=' || - log_flag[log_flag.length () - 1] == '=') - { - g_warning ("string [%s] not parseable", log_flag.c_str()); - continue; - } - - std::vector split_flag; - boost::split (split_flag, log_flag, [](char c){return c == '=';}); - - auto level = qof_log_level_from_string (split_flag[1].c_str()); - qof_log_set_level (split_flag[0].c_str(), level); + g_warning ("string [%s] not parseable", log_flag.c_str()); + continue; } + + std::vector split_flag; + boost::split (split_flag, log_flag, [](char c){return c == '=';}); + + auto level = qof_log_level_from_string (split_flag[1].c_str()); + qof_log_set_level (split_flag[0].c_str(), level); } } diff --git a/gnucash/gnucash-core-app.hpp b/gnucash/gnucash-core-app.hpp index 37dea122d3..ed61af1f28 100644 --- a/gnucash/gnucash-core-app.hpp +++ b/gnucash/gnucash-core-app.hpp @@ -65,7 +65,7 @@ private: bool m_debug = false; bool m_extra = false; boost::optional m_gsettings_prefix; - boost::optional > m_log_flags; + std::vector m_log_flags; char *sys_locale = nullptr; };