diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-08-14 12:23:36 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-08-14 12:30:03 +0200 |
commit | 0acbe6da06dacea303897ac7e78adb084697cecd (patch) | |
tree | c88548eb7ff0dd6d50565ba7acb8ae7024c5b3f7 | |
parent | a423a53865d8e2e57e2b44fdd008cd0feecc00a2 (diff) |
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 <joerg.bornemann@digia.com>
-rw-r--r-- | tests/auto/api/tst_api.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
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) { |