From 0c988e14a90f3e1579365dc3dc99fbdd02ac3d4c Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 5 Apr 2018 17:10:26 +0300 Subject: Start overlapped I/O notifier before any asynchronous operation This commit d57b9e83857253a1479f89fca18ea5856db39fb7 introduced a regression, where the QSP may ignore all the read events when the data comes to the device within opening. In this case, even re-opening of a device does not help. Reason is that the QWinOverlappedIoNotifier is enabled after than the startAsyncCommunication() called, that probably, leads to ignoring for all EV_RXCHAR events. A workaround is to enable the notifier before than any of I/O operation called. Task-number: QTBUG-67224 Change-Id: I21538fddc4dfd850c600e1d74f3c393a59a00549 Reviewed-by: Joerg Bornemann Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- src/serialport/qserialport_win.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index f90a7ef4..85dd8ee2 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -691,15 +691,18 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode) return false; } - if ((eventMask & EV_RXCHAR) && !startAsyncCommunication()) - return false; - notifier = new QWinOverlappedIoNotifier(q); QObjectPrivate::connect(notifier, &QWinOverlappedIoNotifier::notified, this, &QSerialPortPrivate::_q_notified); notifier->setHandle(handle); notifier->setEnabled(true); + if ((eventMask & EV_RXCHAR) && !startAsyncCommunication()) { + delete notifier; + notifier = nullptr; + return false; + } + return true; } -- cgit v1.2.3