summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-03-23 16:18:01 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-24 09:36:33 +0100
commit726571882cd9848c081c6c83c36f2b296d359b1b (patch)
treef93c4e37d60bf0999c300bb97492323f52dd6c8d
parent89acd52d6daea28415dfc313c0c25706ae356f29 (diff)
downloadqtserialport-726571882cd9848c081c6c83c36f2b296d359b1b.tar.gz
Make a good use of the new "override" C++11 specifier when available
The usage of the specifier helps to catch mistakes in general and also explicitly shows the intention. Furthermore, leave the "virtual" specifier out as per Qt Coding Style: http://qt-project.org/wiki/Qt_Coding_Style#fe675674b70cdaca505f3cff0244fbae It does not make much sense in general with the override specifier either anyhow. Note: an empty define is still necessary as long as QtSerialPort supports Qt4 which is the current situation. Change-Id: Iedf01071e6303d88305c140f4a767bb43059f593 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
-rw-r--r--src/serialport/qserialport.h24
-rw-r--r--src/serialport/qserialport_unix.cpp6
-rw-r--r--src/serialport/qserialport_win.cpp8
-rw-r--r--src/serialport/qserialport_wince.cpp2
-rw-r--r--src/serialport/qserialportglobal.h5
5 files changed, 25 insertions, 20 deletions
diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h
index aa87eba..4d837c4 100644
--- a/src/serialport/qserialport.h
+++ b/src/serialport/qserialport.h
@@ -169,8 +169,8 @@ public:
void setPort(const QSerialPortInfo &info);
- virtual bool open(OpenMode mode);
- virtual void close();
+ bool open(OpenMode mode) Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
void setSettingsRestoredOnClose(bool restore);
bool settingsRestoredOnClose() const;
@@ -200,7 +200,7 @@ public:
bool flush();
bool clear(Directions dir = AllDirections);
- virtual bool atEnd() const;
+ bool atEnd() const Q_DECL_OVERRIDE;
bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy);
DataErrorPolicy dataErrorPolicy() const;
@@ -211,14 +211,14 @@ public:
qint64 readBufferSize() const;
void setReadBufferSize(qint64 size);
- virtual bool isSequential() const;
+ bool isSequential() const Q_DECL_OVERRIDE;
- virtual qint64 bytesAvailable() const;
- virtual qint64 bytesToWrite() const;
- virtual bool canReadLine() const;
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE;
+ qint64 bytesToWrite() const Q_DECL_OVERRIDE;
+ bool canReadLine() const Q_DECL_OVERRIDE;
- virtual bool waitForReadyRead(int msecs);
- virtual bool waitForBytesWritten(int msecs);
+ bool waitForReadyRead(int msecs) Q_DECL_OVERRIDE;
+ bool waitForBytesWritten(int msecs) Q_DECL_OVERRIDE;
bool sendBreak(int duration = 0);
bool setBreak(bool set = true);
@@ -237,9 +237,9 @@ Q_SIGNALS:
void settingsRestoredOnCloseChanged(bool restore);
protected:
- virtual qint64 readData(char *data, qint64 maxSize);
- virtual qint64 readLineData(char *data, qint64 maxSize);
- virtual qint64 writeData(const char *data, qint64 maxSize);
+ qint64 readData(char *data, qint64 maxSize) Q_DECL_OVERRIDE;
+ qint64 readLineData(char *data, qint64 maxSize) Q_DECL_OVERRIDE;
+ qint64 writeData(const char *data, qint64 maxSize) Q_DECL_OVERRIDE;
private:
void setError(QSerialPort::SerialPortError error, const QString &errorString = QString());
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 64bfcfb..f16eccc 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -71,7 +71,7 @@ public:
{}
protected:
- virtual bool event(QEvent *e) {
+ bool event(QEvent *e) Q_DECL_OVERRIDE {
bool ret = QSocketNotifier::event(e);
if (ret)
dptr->readNotification();
@@ -91,7 +91,7 @@ public:
{}
protected:
- virtual bool event(QEvent *e) {
+ bool event(QEvent *e) Q_DECL_OVERRIDE {
bool ret = QSocketNotifier::event(e);
if (ret)
dptr->writeNotification(QSerialPortPrivateData::WriteChunkSize);
@@ -111,7 +111,7 @@ public:
{}
protected:
- virtual bool event(QEvent *e) {
+ bool event(QEvent *e) Q_DECL_OVERRIDE {
bool ret = QSocketNotifier::event(e);
if (ret)
dptr->exceptionNotification();
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 07cec11..0e9e18b 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -114,7 +114,7 @@ public:
OVERLAPPED *overlappedPointer() { return &o; }
protected:
- virtual bool event(QEvent *e) {
+ bool event(QEvent *e) Q_DECL_OVERRIDE {
const bool ret = QWinEventNotifier::event(e);
processCompletionRoutine();
return ret;
@@ -137,7 +137,7 @@ public:
void startWaitCommEvent() { ::WaitCommEvent(dptr->descriptor, &triggeredEventMask, &o); }
- virtual bool processCompletionRoutine() {
+ bool processCompletionRoutine() Q_DECL_OVERRIDE {
DWORD numberOfBytesTransferred = 0;
::GetOverlappedResult(dptr->descriptor, &o, &numberOfBytesTransferred, FALSE);
@@ -172,7 +172,7 @@ public:
ReadOverlappedCompletionNotifier(QSerialPortPrivate *d, QObject *parent)
: AbstractOverlappedEventNotifier(d, ReadCompletionEvent, false, parent) {}
- virtual bool processCompletionRoutine() {
+ bool processCompletionRoutine() Q_DECL_OVERRIDE {
DWORD numberOfBytesTransferred = 0;
::GetOverlappedResult(dptr->descriptor, &o, &numberOfBytesTransferred, FALSE);
bool ret = dptr->completeAsyncRead(numberOfBytesTransferred);
@@ -197,7 +197,7 @@ public:
WriteOverlappedCompletionNotifier(QSerialPortPrivate *d, QObject *parent)
: AbstractOverlappedEventNotifier(d, WriteCompletionEvent, false, parent) {}
- virtual bool processCompletionRoutine() {
+ bool processCompletionRoutine() Q_DECL_OVERRIDE {
setEnabled(false);
DWORD numberOfBytesTransferred = 0;
::GetOverlappedResult(dptr->descriptor, &o, &numberOfBytesTransferred, FALSE);
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index 1c5c890..89fd592 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -72,7 +72,7 @@ public:
}
protected:
- virtual void run() {
+ void run() Q_DECL_OVERRIDE {
DWORD mask = 0;
while (running) {
if (::WaitCommEvent(dptr->descriptor, &mask, FALSE)) {
diff --git a/src/serialport/qserialportglobal.h b/src/serialport/qserialportglobal.h
index 6207f46..03cd6a6 100644
--- a/src/serialport/qserialportglobal.h
+++ b/src/serialport/qserialportglobal.h
@@ -57,6 +57,11 @@ QT_BEGIN_NAMESPACE
# define Q_SERIALPORT_EXPORT
#endif
+// The macro has been available only since Qt 5.0
+#ifndef Q_DECL_OVERRIDE
+#define Q_DECL_OVERRIDE
+#endif
+
QT_END_NAMESPACE
#endif // QSERIALPORTGLOBAL_H