From e431acda693abc3d0cd339f95a95220c02ae13bd Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Tue, 18 Sep 2018 18:34:42 +0200 Subject: [PATCH] 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. --- pv/logging.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pv/logging.cpp b/pv/logging.cpp index 377011b..29d023c 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 -- 2.30.2