summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-01-05 14:24:50 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2011-01-07 15:55:37 (GMT)
commit9a6cfc07e5ab21460cd85dbe6ac1f6de62c69524 (patch)
tree9c4869175ba3d91da4fc3732a2fdf75b55a241e6
parent9fd43b8bc40e3b7657dc7eba2dccff95f0d0077a (diff)
downloadQt-9a6cfc07e5ab21460cd85dbe6ac1f6de62c69524.zip
Qt-9a6cfc07e5ab21460cd85dbe6ac1f6de62c69524.tar.gz
Qt-9a6cfc07e5ab21460cd85dbe6ac1f6de62c69524.tar.bz2
Check elapsed time only once
Task-number: QTBUG-16262 Reviewed-by: Bradley T. Hughes
-rw-r--r--src/corelib/thread/qsemaphore.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 8e8a88a..15f45b6 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -223,8 +223,9 @@ bool QSemaphore::tryAcquire(int n, int timeout)
QElapsedTimer timer;
timer.start();
while (n > d->avail) {
- if (timer.hasExpired(timeout)
- || !d->cond.wait(locker.mutex(), timeout - timer.elapsed()))
+ const qint64 elapsed = timer.elapsed();
+ if (timeout - elapsed > 0
+ || !d->cond.wait(locker.mutex(), timeout - elapsed))
return false;
}
}