From d4991e9d720da4af67db746c2afe8a5221fd3647 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Mon, 24 May 2021 19:52:50 +0100 Subject: [PATCH] Reorder log handler thread check to happen before the Win32 messagebox --- src/blackmisc/loghandler.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/blackmisc/loghandler.cpp b/src/blackmisc/loghandler.cpp index 05d5e3482..c7827ac10 100644 --- a/src/blackmisc/loghandler.cpp +++ b/src/blackmisc/loghandler.cpp @@ -47,6 +47,13 @@ namespace BlackMisc { const CStatusMessage statusMessage(type, context, message); const auto invokee = [statusMessage] { CLogHandler::instance()->logLocalMessage(statusMessage); }; + if (type == QtFatalMsg && CLogHandler::instance()->thread() != QThread::currentThread()) + { + // Fatal message means this thread is about to crash the application. A queued connection would be useless. + // Blocking queued connection means we pause this thread just long enough to let the main thread handle the message. + QMetaObject::invokeMethod(CLogHandler::instance(), invokee, Qt::BlockingQueuedConnection); + return; + } #if defined(Q_CC_MSVC) && defined(QT_NO_DEBUG) if (type == QtFatalMsg) { @@ -56,13 +63,6 @@ namespace BlackMisc # endif } #endif - if (type == QtFatalMsg && CLogHandler::instance()->thread() != QThread::currentThread()) - { - // Fatal message means this thread is about to crash the application. A queued connection would be useless. - // Blocking queued connection means we pause this thread just long enough to let the main thread handle the message. - QMetaObject::invokeMethod(CLogHandler::instance(), invokee, Qt::BlockingQueuedConnection); - return; - } QMetaObject::invokeMethod(CLogHandler::instance(), invokee); }