summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-05-26 18:55:01 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-27 09:36:30 +0200
commit04a3308346190a70509a759423993f6bcc365328 (patch)
tree98500fd26f82f843a99049c1d27a7f41a09660b9
parent14a6db457cb1142c0f2e88a5341921d5a33fa2e3 (diff)
downloadqtserialport-04a3308346190a70509a759423993f6bcc365328.tar.gz
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 <dyami@dragonframe.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r--src/serialport/qserialport_win.cpp15
-rw-r--r--src/serialport/qserialport_win_p.h2
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();