From 04a3308346190a70509a759423993f6bcc365328 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 26 May 2014 18:55:01 +0400 Subject: Move out processing of ResoureError from processIoErrors() Handling of the ResourceError is moved directly to _q_completeAsyncCommunication() method. Reasons: * The processIoErrors() should handle only the EV_ERR event. * The handling of ResourceError in the processIoErrors() it is the old heritage when the event processing logic was into the notifiers. Also the method processIoErrors() is renamed in favor to handleLineStatusErrors() for readability, according to documentation on EV_ERR mask: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363479%28v=vs.85%29.aspx Tested build on Windows 7/8 using Qt4 and then Qt5. Change-Id: I6dc331933155f1e182b21f40885e47d574c4ed9f Reviewed-by: Dyami Caliri Reviewed-by: Rafael Roquetto Reviewed-by: Sergey Belyashov --- src/serialport/qserialport_win.cpp | 15 ++++++--------- src/serialport/qserialport_win_p.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 63d0a6d..71521af 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -580,9 +580,11 @@ void QSerialPortPrivate::_q_completeAsyncCommunication() error = true; } - // Start processing a caught error. - if (error || (EV_ERR & triggeredEventMask)) - processIoErrors(error); + if (error) + q->setError(QSerialPort::ResourceError); + + if (EV_ERR & triggeredEventMask) + handleLineStatusErrors(); if (!error) startAsyncRead(); @@ -740,15 +742,10 @@ void QSerialPortPrivate::emitReadyRead() emit q->readyRead(); } -void QSerialPortPrivate::processIoErrors(bool error) +void QSerialPortPrivate::handleLineStatusErrors() { Q_Q(QSerialPort); - if (error) { - q->setError(QSerialPort::ResourceError); - return; - } - DWORD errors = 0; if (!::ClearCommError(handle, &errors, NULL)) { q->setError(decodeSystemError()); diff --git a/src/serialport/qserialport_win_p.h b/src/serialport/qserialport_win_p.h index f6c3b0a..4e66685 100644 --- a/src/serialport/qserialport_win_p.h +++ b/src/serialport/qserialport_win_p.h @@ -88,7 +88,7 @@ public: bool setFlowControl(QSerialPort::FlowControl flowControl); bool setDataErrorPolicy(QSerialPort::DataErrorPolicy policy); - void processIoErrors(bool error); + void handleLineStatusErrors(); QSerialPort::SerialPortError decodeSystemError() const; void _q_completeAsyncCommunication(); -- cgit v1.2.1