qC{Debug,Info,Warning,Critical}: add parentheses around macro argument

Amends ef9fe7a99a9a6779e7133167fe84426bfe9cc371 and fixes some rare
cases where the macro argument wasn't a single token, such as what was
found in PySide code:

      qCDebug(*category, "%s", %2);

Fixes: QTBUG-117153
Change-Id: I85599ea5ca7a4b79a8bbfffd178a51023648f244
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 964b9d7cd4c344b34d999b4d7f5e8185d02d3dac)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0088e32f8e6987384ebe0d083277d02c87cc8b63)
This commit is contained in:
Thiago Macieira 2023-10-02 07:34:39 -07:00 committed by Qt Cherry-pick Bot
parent de65136775
commit 903bb7b22e

View File

@ -117,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__)