From e24c387413b9707622060f381b2a007aa5c814a0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Sep 2019 09:32:25 +0200 Subject: Short live QtPrivate::{condition_variable,mutex}! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a temporary measure to work around an implementation bug on Integrity: For all other platforms, QtPrivate::condition_variable is just std::condition_variable. On Integrity, it's a class that wraps QWaitCondition to provide the interface of std::condition_variable. This allows the use of std::condition_variable across Qt without running into the Integrity issue. Once we can depend on an more modern Integrity toolchain, removing QtPrivate::condition_variable is a simple mechanical change: s/QtPrivate::condition_variable/std::condition_variable/g; s/QtPrivate::mutex/std::mutex/g; Task-number: QTBUG-78450 Change-Id: I293a99d1cdc48691817b926aa51ecd84556e5e90 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e29897abee..5c87844fcd 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -1017,15 +1018,15 @@ class WatchDog : public QThread ThreadEnd, }; - bool waitFor(std::unique_lock &m, Expectation e) { - auto expectation = [this, e] { return expecting != e; }; + bool waitFor(std::unique_lock &m, Expectation e) { + auto expectationChanged = [this, e] { return expecting != e; }; switch (e) { case TestFunctionEnd: - return waitCondition.wait_for(m, defaultTimeout(), expectation); + return waitCondition.wait_for(m, defaultTimeout(), expectationChanged); case ThreadStart: case ThreadEnd: case TestFunctionStart: - waitCondition.wait(m, expectation); + waitCondition.wait(m, expectationChanged); return true; } Q_UNREACHABLE(); @@ -1035,7 +1036,7 @@ class WatchDog : public QThread public: WatchDog() { - std::unique_lock locker(mutex); + auto locker = qt_unique_lock(mutex); expecting = ThreadStart; start(); waitFor(locker, ThreadStart); @@ -1062,7 +1063,7 @@ public: } void run() override { - std::unique_lock locker(mutex); + auto locker = qt_unique_lock(mutex); expecting = TestFunctionStart; waitCondition.notify_all(); while (true) { @@ -1082,8 +1083,8 @@ public: } private: - std::mutex mutex; - std::condition_variable waitCondition; + QtPrivate::mutex mutex; + QtPrivate::condition_variable waitCondition; Expectation expecting; }; -- cgit v1.2.3