]> sigrok.org Git - pulseview.git/commitdiff
Logging: avoid "cb was NULL" warning message during logging shutdown
authorGerhard Sittig <redacted>
Tue, 18 Sep 2018 16:34:42 +0000 (18:34 +0200)
committerUwe Hermann <redacted>
Tue, 18 Sep 2018 20:51:36 +0000 (22:51 +0200)
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

index 377011b68c928a40cf1cf14c590a220ea9ac6ece..29d023c04ad577957aa3a1dbacc52fa0a47acb01 100644 (file)
@@ -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