diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 28f3357e1b..0e9dd3b5ee 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1487,11 +1487,8 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con return message; } -static void qDefaultMsgHandler(QtMsgType type, const char *buf); static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf); -// pointer to QtMsgHandler debug handler (without context) -static QBasicAtomicPointer msgHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr); // pointer to QtMessageHandler debug handler (with context) static QBasicAtomicPointer messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr); @@ -1776,15 +1773,6 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con stderr_message_handler(type, context, message); } -/*! - \internal -*/ -static void qDefaultMsgHandler(QtMsgType type, const char *buf) -{ - QMessageLogContext emptyContext; - qDefaultMessageHandler(type, emptyContext, QString::fromLocal8Bit(buf)); -} - #if defined(Q_COMPILER_THREAD_LOCAL) static thread_local bool msgHandlerGrabbed = false; @@ -1826,14 +1814,8 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex // itself, e.g. by using Qt API if (grabMessageHandler()) { const auto ungrab = qScopeGuard([]{ ungrabMessageHandler(); }); - auto oldStyle = msgHandler.loadAcquire(); - auto newStye = messageHandler.loadAcquire(); - // prefer new message handler over the old one - if (newStye || !oldStyle) { - (newStye ? newStye : qDefaultMessageHandler)(msgType, context, message); - } else { - (oldStyle ? oldStyle : qDefaultMsgHandler)(msgType, message.toLocal8Bit().constData()); - } + auto msgHandler = messageHandler.loadAcquire(); + (msgHandler ? msgHandler : qDefaultMessageHandler)(msgType, context, message); } else { fprintf(stderr, "%s\n", message.toLocal8Bit().constData()); } diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 915f604158..4bd3051cf2 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -32,7 +32,6 @@ QT_CLASS_LIB(QIntegerForSize, QtCore, qglobal.h) QT_CLASS_LIB(Q_INT64, QtCore, qglobal.h) QT_CLASS_LIB(Q_UINT64, QtCore, qglobal.h) QT_CLASS_LIB(QSysInfo, QtCore, qglobal.h) -QT_CLASS_LIB(QtMsgHandler, QtCore, qglobal.h) QT_CLASS_LIB(QGlobalStatic, QtCore, qglobal.h) QT_CLASS_LIB(QGlobalStatic, QtCore, qglobal.h) QT_CLASS_LIB(QGlobalStaticDeleter, QtCore, qglobal.h) diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 41458331a0..cf0fdef109 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -80,15 +80,6 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext &context, con s_message = msg; } -void customMsgHandler(QtMsgType type, const char *msg) -{ - s_type = type; - s_file = 0; - s_line = 0; - s_function = 0; - s_message = QString::fromLocal8Bit(msg); -} - tst_qmessagehandler::tst_qmessagehandler() { // ensure it's unset, otherwise we'll have trouble