gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Mon May 11 15:35:52 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/94fdc42f (commit)
via https://github.com/Gnucash/gnucash/commit/b9b51efa (commit)
from https://github.com/Gnucash/gnucash/commit/3d6a06d5 (commit)
commit 94fdc42f16a2df67cbbf0a31a960edf373ee00b9
Author: John Ralls <jralls at ceridwen.us>
Date: Mon May 11 12:35:42 2020 -0700
Fix wrong Boost library variable names.
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index e03a5f01d..a63efbe63 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -216,8 +216,8 @@ add_dependencies (gnc-engine iso-4217-c)
target_link_libraries(gnc-engine
gnc-core-utils
- ${Boost_DATE_TIME_LIBRARIES}
- ${Boost_REGEX_LIBRARIES}
+ ${Boost_DATE_TIME_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
${ICU4C_I18N_LDFLAGS}
${REGEX_LDFLAGS}
${GMODULE_LDFLAGS}
commit b9b51efa8df888d29b3ab8c13d84384afaff02da
Author: John Ralls <jralls at ceridwen.us>
Date: Mon May 11 12:31:49 2020 -0700
Don't use g_return_value_if_fail in qof_log_check.
It causes GnuCash to crash if g_log is called without having set
G_LOG_DOMAIN.
Also extract a singleton getter function to ensure that the static
root module has been created before use.
diff --git a/libgnucash/engine/qoflog.cpp b/libgnucash/engine/qoflog.cpp
index a0259fc2b..71bcfb097 100644
--- a/libgnucash/engine/qoflog.cpp
+++ b/libgnucash/engine/qoflog.cpp
@@ -69,6 +69,7 @@ static gchar* function_buffer = NULL;
static gint qof_log_num_spaces = 0;
static GLogFunc previous_handler = NULL;
static gchar* qof_logger_format = NULL;
+static QofLogModule log_module = "qof";
using StrVec = std::vector<std::string>;
@@ -85,7 +86,18 @@ struct ModuleEntry
std::vector<ModuleEntryPtr> m_children;
};
-static ModuleEntryPtr modules = NULL;
+static ModuleEntryPtr _modules = NULL;
+
+static ModuleEntryPtr
+get_modules()
+{
+ if (!_modules)
+ {
+ _modules = std::make_shared<ModuleEntry>("");
+ _modules->m_level = QOF_LOG_WARNING;
+ }
+ return _modules;
+}
static StrVec
split_domain (const std::string domain)
@@ -187,8 +199,7 @@ void
qof_log_init_filename(const gchar* log_filename)
{
gboolean warn_about_missing_permission = FALSE;
- if (!modules)
- modules = std::make_shared<ModuleEntry>("");
+ auto modules = get_modules();
if (!qof_logger_format)
qof_logger_format = g_strdup ("* %s %*s <%s> %*s%s%s"); //default format
@@ -233,7 +244,7 @@ qof_log_init_filename(const gchar* log_filename)
fout = stderr;
if (previous_handler == NULL)
- previous_handler = g_log_set_default_handler(log4glib_handler, &modules);
+ previous_handler = g_log_set_default_handler(log4glib_handler, &_modules);
if (warn_about_missing_permission)
{
@@ -256,9 +267,9 @@ qof_log_shutdown (void)
function_buffer = NULL;
}
- if (modules != NULL)
+ if (_modules != NULL)
{
- modules = nullptr;
+ _modules = nullptr;
}
if (previous_handler != NULL)
@@ -273,13 +284,9 @@ qof_log_set_level(QofLogModule log_module, QofLogLevel level)
{
if (!log_module || level == 0)
return;
- if (!modules)
- {
- modules = std::make_shared<ModuleEntry>("");
- modules->m_level = QOF_LOG_WARNING;
- }
+
auto module_parts = split_domain(log_module);
- auto module = modules;
+ auto module = get_modules();
for (auto part : module_parts)
{
auto iter = std::find_if(module->m_children.begin(),
@@ -305,11 +312,25 @@ qof_log_set_level(QofLogModule log_module, QofLogLevel level)
gboolean
qof_log_check(QofLogModule domain, QofLogLevel level)
{
- g_return_val_if_fail (domain && level && modules, FALSE);
- if (level < modules->m_level)
+
+ if (!domain)
+ {
+ PWARN ("Domain not set");
+ return FALSE;
+ }
+
+ if (!level)
+ {
+ PWARN("0 is not a valid log level");
+ return FALSE;
+ }
+
+ auto module = get_modules();
+ // If the level is < the default then no need to look further.
+ if (level < module->m_level)
return TRUE;
auto domain_vec = split_domain(domain);
- auto module = modules;
+
for (auto part : domain_vec)
{
auto iter = std::find_if(module->m_children.begin(),
@@ -463,6 +484,7 @@ qof_log_set_default(QofLogLevel log_level)
{
qof_log_set_level("", log_level);
qof_log_set_level("qof", log_level);
+ qof_log_set_level("qof.unknown", log_level);
}
const gchar*
Summary of changes:
libgnucash/engine/CMakeLists.txt | 4 ++--
libgnucash/engine/qoflog.cpp | 52 ++++++++++++++++++++++++++++------------
2 files changed, 39 insertions(+), 17 deletions(-)
More information about the gnucash-changes
mailing list