diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2016-07-30 14:34:33 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2016-08-09 05:35:10 +0000 |
commit | 8bbc260534a4c77e5a22a375eb6becc2fa5edf6d (patch) | |
tree | 3ff23fc860ff00512eff014392d90f07daa3c69f | |
parent | 8fa108de666e815053c6e586f1efabc592ae20a5 (diff) |
Replace QSP::error signal with QSP::errorOccurred
Make the name of the signal and the name of the getter unambiguous,
which in turn allows the easy use of Qt 5-style connects.
This commit message was taken from commit qtbase/4672e31.
[ChangeLog][QtSerialPort][QSerialPort] Deprecated QSP::error()
signal in favor of new QSP::errorOccurred() one.
Change-Id: I3f04bb8b1ae686d5368d43741cd0e97748b31b8f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r-- | src/serialport/qserialport.cpp | 17 | ||||
-rw-r--r-- | src/serialport/qserialport.h | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 02a9422b..e62cf694 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -131,6 +131,7 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo) error = errorInfo.errorCode; q->setErrorString(errorInfo.errorString); + emit q->errorOccurred(error); emit q->error(error); } @@ -197,6 +198,10 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo) If \l{QIODevice::}{waitForReadyRead()} returns false, the connection has been closed or an error has occurred. + If an error occurs at any point in time, QSerialPort will emit the + errorOccurred() signal. You can also call error() to find the type of + error that occurred last. + Programming with a blocking serial port is radically different from programming with a non-blocking serial port. A blocking serial port does not require an event loop and typically leads to simpler code. @@ -1166,9 +1171,17 @@ void QSerialPort::clearError() /*! \fn void QSerialPort::error(SerialPortError error) + \obsolete + + Use errorOccurred() instead. +*/ + +/*! + \fn void QSerialPort::errorOccurred(SerialPortError error) + \since 5.8 - This signal is emitted after the error has been changed. The new error - is passed as \a error. + This signal is emitted when an error occurs in the serial port. + The specified \a error describes the type of error that occurred. \sa QSerialPort::error */ diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h index 0a7ab0f3..e4a61eda 100644 --- a/src/serialport/qserialport.h +++ b/src/serialport/qserialport.h @@ -284,7 +284,10 @@ Q_SIGNALS: #endif void dataTerminalReadyChanged(bool set); void requestToSendChanged(bool set); +#if QT_DEPRECATED_SINCE(5, 8) void error(QSerialPort::SerialPortError serialPortError); +#endif + void errorOccurred(QSerialPort::SerialPortError error); #if QT_DEPRECATED_SINCE(5, 5) QT_DEPRECATED void settingsRestoredOnCloseChanged(bool restore); #endif |