diff options
author | Laszlo Papp <lpapp@kde.org> | 2013-11-01 03:47:13 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-01 15:14:59 +0100 |
commit | 93e887866c2a44957243d12b469ac0f74f3a7eef (patch) | |
tree | 312a646ca43a08f8712b45c7e42ae676bf993775 /src/serialport/qserialport.h | |
parent | 9181a898650158cd73f14edf105ee6d5b12eb7f7 (diff) | |
download | qtserialport-93e887866c2a44957243d12b469ac0f74f3a7eef.tar.gz |
Mark most of the the data error policy as deprecated
Unfortunately, this is a bit bad heritage of the QSerialDevice project. It is
not well-thought, and it was added in rush. If this feature ever comes back,
it has to be rethought and maybe redesigned. Currently, it is not much usable
nicely. It is done similarly to the following change:
https://codereview.qt-project.org/#patch,all,43441,7
Having done this, the users will get a warning, and they will hopefully stop
using it. Then, the feature redesign it for 5.3 or later. It can get
undeprecated anytime in Qt 5.X, but it cannot be removed with bumping the
library version. That should be the last resort.
In fact, this feature is very likely not to be redesigned. It is unfortunately a
broken concept. The following long-living serial port frameworks do not provide
"Policy" API either which is a clear sign for its usage pattern:
* PySerial
* Java SerialPort
* C#/.NET SerialPort
* QextSerialPort
... so to recap: it was not a good idea to introduce it.
Unfortunately, the side effect is that we have got warnings for the deprecated
method since moc cannot handle it properly. It needs to call it for internal
reasons.
Note that enum and Q_PROPERTY cannot be deprecated because Q_PROPERTY simply
cannot be, and the enum cannot be deprecated either since that would cause
further warnings for the library itself due its usage for the accessor and
mutator, etc. However, they can be put behind the QT_DEPRECATED_SINCE macro so
that the users can get compilation errors if they define
QT_DISABLE_DEPRECATED_BEFORE to get rid of old deprecated symbols easily by
getting errors instead of warnings.
The following coding can be run to show the expected warnings when used from a
QtSerialPort based application or library:
main.cpp:
int main()
{
QSerialPort serialPort;
serialPort.dataErrorPolicy();
return 0;
}
==============================================================================
1) Qt 5
g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt -lQt5SerialPort main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
serialPort.dataErrorPolicy();
Tested on Linux with Qt 4.8.5 and then Qt 5.1.1.
==============================================================================
2) Qt 4
g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt4/ -lQtSerialPort main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt4/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
serialPort.dataErrorPolicy();
^
==============================================================================
Task-number: QTBUG-34429
Change-Id: Ia183817b841fb172d232f550b8402f7a314b8492
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport.h')
-rw-r--r-- | src/serialport/qserialport.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h index e173445..ada19fb 100644 --- a/src/serialport/qserialport.h +++ b/src/serialport/qserialport.h @@ -47,6 +47,10 @@ #include <QtSerialPort/qserialportglobal.h> +#ifndef QT_DEPRECATED_SINCE +#define QT_DEPRECATED_SINCE(major, minor) 1 +#endif + QT_BEGIN_NAMESPACE class QSerialPortInfo; @@ -62,7 +66,9 @@ class Q_SERIALPORT_EXPORT QSerialPort : public QIODevice Q_PROPERTY(Parity parity READ parity WRITE setParity NOTIFY parityChanged) Q_PROPERTY(StopBits stopBits READ stopBits WRITE setStopBits NOTIFY stopBitsChanged) Q_PROPERTY(FlowControl flowControl READ flowControl WRITE setFlowControl NOTIFY flowControlChanged) +#if QT_DEPRECATED_SINCE(5, 2) Q_PROPERTY(DataErrorPolicy dataErrorPolicy READ dataErrorPolicy WRITE setDataErrorPolicy NOTIFY dataErrorPolicyChanged) +#endif Q_PROPERTY(bool dataTerminalReady READ isDataTerminalReady WRITE setDataTerminalReady NOTIFY dataTerminalReadyChanged) Q_PROPERTY(bool requestToSend READ isRequestToSend WRITE setRequestToSend NOTIFY requestToSendChanged) Q_PROPERTY(SerialPortError error READ error RESET clearError NOTIFY error) @@ -145,6 +151,7 @@ public: }; Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal) +#if QT_DEPRECATED_SINCE(5, 2) enum DataErrorPolicy { SkipPolicy, PassZeroPolicy, @@ -152,6 +159,7 @@ public: StopReceivingPolicy, UnknownPolicy = -1 }; +#endif enum SerialPortError { NoError, @@ -213,8 +221,10 @@ public: bool clear(Directions directions = AllDirections); bool atEnd() const Q_DECL_OVERRIDE; - bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy); - DataErrorPolicy dataErrorPolicy() const; +#if QT_DEPRECATED_SINCE(5, 2) + QT_DEPRECATED bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy); + QT_DEPRECATED DataErrorPolicy dataErrorPolicy() const; +#endif SerialPortError error() const; void clearError(); |