diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2015-08-05 10:48:39 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2015-08-06 12:21:09 +0000 |
commit | 16da7879b10159e459e21a743686b8b8a91fdcd7 (patch) | |
tree | 40c2da574fb7f155492b4af3bde1c7ae2a8af5d3 | |
parent | d681e0acef9463f9b346fd89a1ecedaf66cb5344 (diff) | |
download | qtserialport-16da7879b10159e459e21a743686b8b8a91fdcd7.tar.gz |
Delete the notifiers immediatelly on close
This avoid of the errors when the triggered notifier tries
to handle an already closed device descriptor.
Tested on Windows and Linux with the USB serial ports.
(cherry-picked from 1651383fd030189366f2e13de4da3d37319e705e)
Change-Id: Iceb2e8c202b2b8d28fc87fa3a1b817df4caf39b9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 6 | ||||
-rw-r--r-- | src/serialport/qserialport_win.cpp | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 98d6622..48dd196 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -231,14 +231,12 @@ void QSerialPortPrivate::close() #endif if (readNotifier) { - readNotifier->setEnabled(false); - readNotifier->deleteLater(); + delete readNotifier; readNotifier = Q_NULLPTR; } if (writeNotifier) { - writeNotifier->setEnabled(false); - writeNotifier->deleteLater(); + delete writeNotifier; writeNotifier = Q_NULLPTR; } diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index d3eda5f..73f9bab 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -153,9 +153,20 @@ void QSerialPortPrivate::close() if (!::CancelIo(handle)) setError(getSystemError()); - setReadNotificationEnabled(false); - setWriteNotificationEnabled(false); - setCommunicationNotificationEnabled(false); + if (communicationNotifier) { + delete communicationNotifier; + communicationNotifier = Q_NULLPTR; + } + + if (readCompletionNotifier) { + delete readCompletionNotifier; + readCompletionNotifier = Q_NULLPTR; + } + + if (writeCompletionNotifier) { + delete writeCompletionNotifier; + writeCompletionNotifier = Q_NULLPTR; + } readStarted = false; readBuffer.clear(); |