Deal with null pointers in QMessageLogContext instances

This commit is contained in:
Bill Somerville 2020-09-27 16:16:55 +01:00
parent 68a083b9bf
commit 6ab7889cd4
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F

View File

@ -201,7 +201,17 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
// Map non-default Qt categories to logger channels, Qt logger
// context is mapped to the appropriate logger attributes.
auto log = Logger::sys::get ();
if (!qstrcmp (context.category, "default"))
std::wstring file;
std::wstring function;
if (context.file)
{
file = context.file;
}
if (context.function)
{
function = context.function;
}
if (!context.category || !qstrcmp (context.category, "default"))
{
BOOST_LOG_SEV (log, severity)
<< boost::log::add_value ("Line", context.line)
@ -211,7 +221,7 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
}
else
{
BOOST_LOG_CHANNEL_SEV (log, QString {context.category}.toStdWString (), severity)
BOOST_LOG_CHANNEL_SEV (log, std::wstring {context.category}, severity)
<< boost::log::add_value ("Line", context.line)
<< boost::log::add_value ("File", context.file)
<< boost::log::add_value ("Function", context.function)