From 16cf095bd5018d8fd935233c3fa54eb85c685ea3 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 20 May 2023 11:14:00 +0200 Subject: [PATCH] Silence warning from unused variable in QObject test It's not needed, but makes the point for having a mutable lambda in the first place. Change-Id: I483862d6aee90bb62d4b5363c56a80bb05e14df7 Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 5cb9faf01f3..73b77932ce4 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -8586,7 +8586,11 @@ void tst_QObject::asyncCallbackHelper() QCOMPARE(called, 1); QMetaObject::invokeMethod(this, [&called, u = std::unique_ptr()]{ called = 2; }); QCOMPARE(called, 2); - QMetaObject::invokeMethod(this, [&called, count = 0]() mutable { called = 3; }); + QMetaObject::invokeMethod(this, [&called, count = 0]() mutable { + if (!count) + called = 3; + ++count; + }); QCOMPARE(called, 3); } }