Logging: Don't use for loop in qCDebug macros

The local 'enabled' variable might cause dubious MSVC warnings
if a local variable name 'enabled' exists.

Just replace the whole loop with the if (...); else idiom, as Thiago
once suggested on the mailing list.

Task-number: QTBUG-36605
Change-Id: I0b8959a29d4432296961493fe2b7827c5b860d00
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
bb10
Kai Koehne 2014-02-03 16:30:26 +01:00 committed by The Qt Project
parent 6d48df83ab
commit 2edf3ba5a7
1 changed files with 3 additions and 3 deletions

View File

@ -97,13 +97,13 @@ private:
#ifdef Q_COMPILER_VARIADIC_MACROS
#define qCDebug(category, ...) \
for (bool enabled = category().isDebugEnabled(); Q_UNLIKELY(enabled); enabled = false) \
if (!category().isDebugEnabled()) {} else \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__)
#define qCWarning(category, ...) \
for (bool enabled = category().isWarningEnabled(); enabled; enabled = false) \
if (!category().isWarningEnabled()) {} else \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning(__VA_ARGS__)
#define qCCritical(category, ...) \
for (bool enabled = category().isCriticalEnabled(); enabled; enabled = false) \
if (!category().isCriticalEnabled()) {} else \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical(__VA_ARGS__)
#else