From 0b984e141bff9ae760efa0e81a9f106093552538 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 12 Aug 2019 10:58:06 +0200 Subject: Bound the scope of QTRY_LOOP_IMPL()'s local variable QTRY_IMPL() exercises QTRY_LOOP_IMPL() twice, once directly, the second time via QTRY_TIMEOUT_DEBUG_IMPL(); and QTRY_LOOP_IMPL() deliberately doesn't bound its scope (e.g. with the canonical do{...}while(0) trick) so that the latter can access its local variable. Unfortunately, this means the local's declaration in the second use of QTRY_LOOP_IMPL() shadows the first. So enclose the first in braces to bound the scope. Fixes: QTBUG-77297 Change-Id: I849bfe0b8abfb517ed3e783abf86c602163db137 Reviewed-by: Marc Mutz --- src/testlib/qtestcase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 5fed9d6bcc..6e865f1278 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -152,7 +152,7 @@ do {\ #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \ const int qt_test_timeoutValue = timeout; \ - QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); \ + { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \ QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step)\ // Will try to wait for the expression to become true while allowing event processing -- cgit v1.2.3