summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2013-09-08 22:43:57 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 19:45:53 +0200
commit728f3e7383ac6f7364126bf55684d51dec51cd69 (patch)
tree27a88d63456d8815600209d87995f93b0ecbc004
parent0f52055ff79781af865dc38d7ee7ccb2b539cda2 (diff)
downloadqtserialport-old/5.1.tar.gz
Do not time out for -1 msec (wait methods)old/5.1
According to the documentation of QIODevice: * http://qt-project.org/doc/qt-5.1/qtcore/qiodevice.html#waitForBytesWritten * http://qt-project.org/doc/qt-5.1/qtcore/qiodevice.html#waitForReadyRead these wait methods should not time out if msecs is -1. Currently, the behavior does not match the expected behavior as the negative values were overridden by zero. The operation returns as soon as the event loop processing happens. Now this problem is solved for Windows: the INFINITE flag has been added to the WaitForMultipleObjects call. See the MSDN documentation for details below: http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025%28v=vs.85%29.aspx Note: the check is added only for -1 to be consistent with the behavior of other QIODevice subclasses. If it is any other negative integer, the value will be cast to the corresponding positive value which will indicate the waiting time. Tested with Qt4 and then Qt5. Change-Id: I2b8c8310723bca7beb9af0213edf4c855b5ac6ae Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r--src/serialport/qserialport_win.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index c515e82..1ab18a9 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -985,7 +985,7 @@ bool QSerialPortPrivate::waitAnyEvent(int msecs, bool *timedOut,
DWORD waitResult = ::WaitForMultipleObjects(handles.count(),
handles.constData(),
FALSE, // wait any event
- qMax(msecs, 0));
+ msecs == -1 ? INFINITE : msecs);
if (waitResult == WAIT_TIMEOUT) {
*timedOut = true;
return false;