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.
This commit is contained in:
Geert Janssens 2020-11-13 10:58:14 +01:00
parent 79951e094f
commit e9a117b21b
2 changed files with 14 additions and 17 deletions

View File

@ -346,7 +346,7 @@ load_user_config(void)
static void static void
gnc_log_init (const boost::optional <std::vector <std::string>> &log_flags, gnc_log_init (const std::vector <std::string> log_flags,
const boost::optional <std::string> &log_to_filename) const boost::optional <std::string> &log_to_filename)
{ {
if (log_to_filename && !log_to_filename->empty()) if (log_to_filename && !log_to_filename->empty())
@ -389,9 +389,7 @@ gnc_log_init (const boost::optional <std::vector <std::string>> &log_flags,
qof_log_parse_log_config (log_config_filename); qof_log_parse_log_config (log_config_filename);
g_free (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 () || if (log_flag.empty () ||
log_flag[0] == '=' || log_flag[0] == '=' ||
@ -408,7 +406,6 @@ gnc_log_init (const boost::optional <std::vector <std::string>> &log_flags,
qof_log_set_level (split_flag[0].c_str(), level); qof_log_set_level (split_flag[0].c_str(), level);
} }
} }
}
Gnucash::CoreApp::CoreApp () Gnucash::CoreApp::CoreApp ()
{ {

View File

@ -65,7 +65,7 @@ private:
bool m_debug = false; bool m_debug = false;
bool m_extra = false; bool m_extra = false;
boost::optional <std::string> m_gsettings_prefix; boost::optional <std::string> m_gsettings_prefix;
boost::optional <std::vector <std::string>> m_log_flags; std::vector <std::string> m_log_flags;
char *sys_locale = nullptr; char *sys_locale = nullptr;
}; };