From: Gerhard Sittig Date: Tue, 18 Sep 2018 16:34:42 +0000 (+0200) Subject: Logging: avoid "cb was NULL" warning message during logging shutdown X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e431acda693abc3d0cd339f95a95220c02ae13bd;p=pulseview.git Logging: avoid "cb was NULL" warning message during logging shutdown Commit 4b9234088f56 introduced the fetch and restore of the libraries' default log routines in addition to the registration of a Pulseview application's log routine. Some code paths in main() could result in unexpected "cb was NULL" messages on stderr, when logging::init() did not execute but the destructor tried to restore a handler which was not fetched before. Silence the error message. --- diff --git a/pv/logging.cpp b/pv/logging.cpp index 377011b6..29d023c0 100644 --- a/pv/logging.cpp +++ b/pv/logging.cpp @@ -52,11 +52,13 @@ static void *prev_srd_log_cb_data; Logging::~Logging() { qInstallMessageHandler(nullptr); - sr_log_callback_set(prev_sr_log_cb, prev_sr_log_cb_data); + if (prev_sr_log_cb) + sr_log_callback_set(prev_sr_log_cb, prev_sr_log_cb_data); prev_sr_log_cb = nullptr; prev_sr_log_cb_data = nullptr; #ifdef ENABLE_DECODE - srd_log_callback_set(prev_srd_log_cb, prev_srd_log_cb_data); + if (prev_srd_log_cb) + srd_log_callback_set(prev_srd_log_cb, prev_srd_log_cb_data); prev_srd_log_cb = nullptr; prev_srd_log_cb_data = nullptr; #endif