summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-12-18 22:53:14 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2016-01-11 09:26:30 +0000
commit4ff8b20cf2877298c8437fb892ebda600f46e293 (patch)
tree7bca3c7329ac465a79d2965d29e5e13d63983d2a /src
parentafe2f2386ecfdc3d0d3fe46f7d1662ab0b6851ce (diff)
downloadqtserialport-4ff8b20cf2877298c8437fb892ebda600f46e293.tar.gz
Suppress error emission when closing
When the error signal is connected to a slot which calls QSP::close() and an error occurs in this method, this would lead to infinite recursion. Other Qt I/O classes avoid this problem by not emitting errors while closing the device, so we should not, either. Task-number: QTBUG-50052 Change-Id: Icfbcb19c32b8bd7fc586ab5253dc754e78829f11 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qserialport_unix.cpp12
-rw-r--r--src/serialport/qserialport_win.cpp13
2 files changed, 8 insertions, 17 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 960349e..7153449 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -237,14 +237,11 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
void QSerialPortPrivate::close()
{
- if (settingsRestoredOnClose) {
- if (::tcsetattr(descriptor, TCSANOW, &restoredTermios) == -1)
- setError(getSystemError());
- }
+ if (settingsRestoredOnClose)
+ ::tcsetattr(descriptor, TCSANOW, &restoredTermios);
#ifdef TIOCNXCL
- if (::ioctl(descriptor, TIOCNXCL) == -1)
- setError(getSystemError());
+ ::ioctl(descriptor, TIOCNXCL);
#endif
if (readNotifier) {
@@ -257,8 +254,7 @@ void QSerialPortPrivate::close()
writeNotifier = Q_NULLPTR;
}
- if (qt_safe_close(descriptor) == -1)
- setError(getSystemError());
+ qt_safe_close(descriptor);
lockFileScopedPointer.reset(Q_NULLPTR);
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 6e1a44f..f176025 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -104,8 +104,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
void QSerialPortPrivate::close()
{
- if (!::CancelIo(handle))
- setError(getSystemError());
+ ::CancelIo(handle);
if (notifier) {
delete notifier;
@@ -124,15 +123,11 @@ void QSerialPortPrivate::close()
actualBytesToWrite = 0;
if (settingsRestoredOnClose) {
- if (!::SetCommState(handle, &restoredDcb))
- setError(getSystemError());
- else if (!::SetCommTimeouts(handle, &restoredCommTimeouts))
- setError(getSystemError());
+ ::SetCommState(handle, &restoredDcb);
+ ::SetCommTimeouts(handle, &restoredCommTimeouts);
}
- if (!::CloseHandle(handle))
- setError(getSystemError());
-
+ ::CloseHandle(handle);
handle = INVALID_HANDLE_VALUE;
}