diff options
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 7eb917c71f..f2655dab3c 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1629,6 +1629,23 @@ QString QIODevice::errorString() const \sa read(), write() */ +/*! + \internal + \fn int qt_subtract_from_timeout(int timeout, int elapsed) + + Reduces the \a timeout by \a elapsed, taking into account that -1 is a + special value for timeouts. +*/ + +int qt_subtract_from_timeout(int timeout, int elapsed) +{ + if (timeout == -1) + return -1; + + timeout = timeout - elapsed; + return timeout < 0 ? 0 : timeout; +} + #if !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, QIODevice::OpenMode modes) |