qC{Debug,Info,Warning,Critical}: move the function call to the macro

The change in commit 04ee5795cc31ee81fb0c27bf55d9e8f662995753 was
source-incompatible if the function in question was a non-static member.
I could add a new, template constructor to catch those, but this is
simpler.

Fixes: QTBUG-115043
Change-Id: I53335f845a1345299031fffd176f1071afbae7a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ef9fe7a99a9a6779e7133167fe84426bfe9cc371)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2023-07-05 12:47:45 -07:00 committed by Qt Cherry-pick Bot
parent bccb6c13f0
commit 2e70ca4847

View File

@ -67,11 +67,6 @@ template <QtMsgType Which> struct QLoggingCategoryMacroHolder
if (IsOutputEnabled)
init(cat);
}
explicit QLoggingCategoryMacroHolder(QMessageLogger::CategoryFunction catfunc)
{
if (IsOutputEnabled)
init(catfunc());
}
void init(const QLoggingCategory &cat) noexcept
{
category = &cat;
@ -122,7 +117,7 @@ template <> const bool QLoggingCategoryMacroHolder<QtWarningMsg>::IsOutputEnable
}
#define QT_MESSAGE_LOGGER_COMMON(category, level) \
for (QLoggingCategoryMacroHolder<level> qt_category(category); qt_category; qt_category.control = false) \
for (QLoggingCategoryMacroHolder<level> qt_category(category()); qt_category; qt_category.control = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, qt_category.name())
#define qCDebug(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtDebugMsg).debug(__VA_ARGS__)