summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qwinoverlappedionotifier.cpp
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@theqtcompany.com>2014-12-08 15:29:19 +0100
committerDaniel Teske <daniel.teske@theqtcompany.com>2015-03-09 17:11:54 +0000
commited0c0070f9b05c647019270dfc42073d071c830a (patch)
tree59a4996d3de61489254b3cb8a85b6d2c83a19bd3 /src/corelib/io/qwinoverlappedionotifier.cpp
parent5bf9528b9164bd888e991552b66d6237e84a7ee2 (diff)
Introduce qt_subtract_from_timeout to reduce code duplication.
The same qt_timeout_value function was copied 5 times in qtbase's code, so provide a common implementation in QIoDevice that can be used by everyone. This commit also corrects the remaining time calculation in QProcess::waitForBytesWritten and QProcess::waitForFinished by using this new function. For QProcess::waitForFinished, if the process started within almost exactly the timeout time passed to waitForFinished, msecs - stopWatch.elapsed() would be -1, which is a special value. Change-Id: I7b76ee6bae695eafdd02e3db03e2ff1e23a7f40c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib/io/qwinoverlappedionotifier.cpp')
-rw-r--r--src/corelib/io/qwinoverlappedionotifier.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp
index de0e205d26..7a005430ea 100644
--- a/src/corelib/io/qwinoverlappedionotifier.cpp
+++ b/src/corelib/io/qwinoverlappedionotifier.cpp
@@ -41,6 +41,7 @@
#include <qthread.h>
#include <qt_windows.h>
#include <private/qobject_p.h>
+#include <private/qiodevice_p.h>
QT_BEGIN_NAMESPACE
@@ -332,11 +333,9 @@ bool QWinOverlappedIoNotifier::waitForNotified(int msecs, OVERLAPPED *overlapped
return false;
if (triggeredOverlapped == overlapped)
return true;
- if (msecs != -1) {
- t = msecs - stopWatch.elapsed();
- if (t < 0)
- return false;
- }
+ msecs = qt_subtract_from_timeout(msecs, stopWatch.elapsed());
+ if (t == 0)
+ return false;
}
}