diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2019-08-12 10:58:06 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-08-13 11:51:10 +0200 |
commit | 0b984e141bff9ae760efa0e81a9f106093552538 (patch) | |
tree | 969e4ee92f3d0625bcd42e5349abff0ad72046bb /src/testlib | |
parent | 7f4f346e51b0479a0ab0b927e586e6c626028b4b (diff) |
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 <marc.mutz@kdab.com>
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestcase.h | 2 |
1 files changed, 1 insertions, 1 deletions
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 |