From 2edf3ba5a718415e5a9a327156289bed4484cdea Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 3 Feb 2014 16:30:26 +0100 Subject: [PATCH] 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 --- src/corelib/io/qloggingcategory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 1e8823e92b..37735908a1 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -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