From 8bbc260534a4c77e5a22a375eb6becc2fa5edf6d Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 30 Jul 2016 14:34:33 +0300 Subject: 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 Reviewed-by: Denis Shienkov --- src/serialport/qserialport.cpp | 17 +++++++++++++++-- src/serialport/qserialport.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 02a9422..e62cf69 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 0a7ab0f..e4a61ed 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 -- cgit v1.2.1