From 0acbe6da06dacea303897ac7e78adb084697cecd Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 14 Aug 2014 12:23:36 +0200 Subject: Fix race condition in API test. The waitForFinished() function will run indefinitely if the job has already finished. This can happen in the projectLocking test, which calls the function for two jobs, but cannot know which one of them will finish first. Change-Id: I44c3e0550c0a287d96b0a79a9064455ecaaf7437 Reviewed-by: Joerg Bornemann --- tests/auto/api/tst_api.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index ceea0f4c4..687863876 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -96,6 +96,8 @@ void TestApi::initTestCase() static bool waitForFinished(qbs::AbstractJob *job, int timeout = 0) { + if (job->state() == qbs::AbstractJob::StateFinished) + return true; QEventLoop loop; QObject::connect(job, SIGNAL(finished(bool,qbs::AbstractJob*)), &loop, SLOT(quit())); if (timeout > 0) { -- cgit v1.2.3