Skip to content

Commit eb2ffbb

Browse files
author
MarcoFalke
committed
Merge #18914: refactor: Apply override specifier consistently
d044e0e refactor: Remove override for final overriders (Hennadii Stepanov) 1551cea refactor: Use override for non-final overriders (Hennadii Stepanov) Pull request description: Two commits are split out from #16710 to make reviewing [easier](bitcoin/bitcoin#16710 (comment)). From [C++ FAQ](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final): > C.128: Virtual functions should specify exactly one of virtual, override, or final > **Reason** Readability. Detection of mistakes. Writing explicit `virtual`, `override`, or `final` is self-documenting and enables the compiler to catch mismatch of types and/or names between base and derived classes. However, writing more than one of these three is both redundant and a potential source of errors. ACKs for top commit: practicalswift: ACK d044e0e: consistent use of `override` prevents bugs + patch looks correct + Travis happy MarcoFalke: ACK d044e0e, based on my understanding that adding `override` or `final` to a function must always be correct, unless it doesn't compile!? vasild: ACK d044e0e Tree-SHA512: 245fd9b99b8b5cbf8694061f892cb3435f3378c97ebed9f9401ce86d21890211f2234bcc39c9f0f79a4d2806cb31bf8ce41a0f9c2acef4f3a2ac5beca6b077cf
2 parents f71a3a8 + d044e0e commit eb2ffbb

37 files changed

+108
-107
lines changed

src/interfaces/chain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RpcHandlerImpl : public Handler
127127
::tableRPC.appendCommand(m_command.name, &m_command);
128128
}
129129

130-
void disconnect() override final
130+
void disconnect() final
131131
{
132132
if (m_wrapped_command) {
133133
m_wrapped_command = nullptr;

src/qt/addressbookpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
3535
}
3636

3737
protected:
38-
bool filterAcceptsRow(int row, const QModelIndex& parent) const
38+
bool filterAcceptsRow(int row, const QModelIndex& parent) const override
3939
{
4040
auto model = sourceModel();
4141
auto label = model->index(row, AddressTableModel::Label, parent);

src/qt/addressbookpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AddressBookPage : public QDialog
4545
const QString &getReturnValue() const { return returnValue; }
4646

4747
public Q_SLOTS:
48-
void done(int retval);
48+
void done(int retval) override;
4949

5050
private:
5151
Ui::AddressBookPage *ui;

src/qt/addresstablemodel.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class AddressTableModel : public QAbstractTableModel
5252

5353
/** @name Methods overridden from QAbstractTableModel
5454
@{*/
55-
int rowCount(const QModelIndex &parent) const;
56-
int columnCount(const QModelIndex &parent) const;
57-
QVariant data(const QModelIndex &index, int role) const;
58-
bool setData(const QModelIndex &index, const QVariant &value, int role);
59-
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
60-
QModelIndex index(int row, int column, const QModelIndex &parent) const;
61-
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
62-
Qt::ItemFlags flags(const QModelIndex &index) const;
55+
int rowCount(const QModelIndex &parent) const override;
56+
int columnCount(const QModelIndex &parent) const override;
57+
QVariant data(const QModelIndex &index, int role) const override;
58+
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
59+
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
60+
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
61+
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
62+
Qt::ItemFlags flags(const QModelIndex &index) const override;
6363
/*@}*/
6464

6565
/* Add an address to the model.

src/qt/askpassphrasedialog.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AskPassphraseDialog : public QDialog
3232
explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr);
3333
~AskPassphraseDialog();
3434

35-
void accept();
35+
void accept() override;
3636

3737
void setModel(WalletModel *model);
3838

@@ -49,8 +49,8 @@ private Q_SLOTS:
4949
void toggleShowPassword(bool);
5050

5151
protected:
52-
bool event(QEvent *event);
53-
bool eventFilter(QObject *object, QEvent *event);
52+
bool event(QEvent *event) override;
53+
bool eventFilter(QObject *object, QEvent *event) override;
5454
};
5555

5656
#endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H

src/qt/bantablemodel.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ class BanTableModel : public QAbstractTableModel
5656

5757
/** @name Methods overridden from QAbstractTableModel
5858
@{*/
59-
int rowCount(const QModelIndex &parent) const;
60-
int columnCount(const QModelIndex &parent) const;
61-
QVariant data(const QModelIndex &index, int role) const;
62-
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
63-
QModelIndex index(int row, int column, const QModelIndex &parent) const;
64-
Qt::ItemFlags flags(const QModelIndex &index) const;
65-
void sort(int column, Qt::SortOrder order);
66-
bool shouldShow();
59+
int rowCount(const QModelIndex &parent) const override;
60+
int columnCount(const QModelIndex &parent) const override;
61+
QVariant data(const QModelIndex &index, int role) const override;
62+
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
63+
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
64+
Qt::ItemFlags flags(const QModelIndex &index) const override;
65+
void sort(int column, Qt::SortOrder order) override;
6766
/*@}*/
6867

68+
bool shouldShow();
69+
6970
public Q_SLOTS:
7071
void refresh();
7172

src/qt/bitcoinaddressvalidator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BitcoinAddressEntryValidator : public QValidator
1717
public:
1818
explicit BitcoinAddressEntryValidator(QObject *parent);
1919

20-
State validate(QString &input, int &pos) const;
20+
State validate(QString &input, int &pos) const override;
2121
};
2222

2323
/** Bitcoin address widget validator, checks for a valid bitcoin address.
@@ -29,7 +29,7 @@ class BitcoinAddressCheckValidator : public QValidator
2929
public:
3030
explicit BitcoinAddressCheckValidator(QObject *parent);
3131

32-
State validate(QString &input, int &pos) const;
32+
State validate(QString &input, int &pos) const override;
3333
};
3434

3535
#endif // BITCOIN_QT_BITCOINADDRESSVALIDATOR_H

src/qt/bitcoinamountfield.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AmountSpinBox: public QAbstractSpinBox
3131
connect(lineEdit(), &QLineEdit::textEdited, this, &AmountSpinBox::valueChanged);
3232
}
3333

34-
QValidator::State validate(QString &text, int &pos) const
34+
QValidator::State validate(QString &text, int &pos) const override
3535
{
3636
if(text.isEmpty())
3737
return QValidator::Intermediate;
@@ -41,7 +41,7 @@ class AmountSpinBox: public QAbstractSpinBox
4141
return valid ? QValidator::Intermediate : QValidator::Invalid;
4242
}
4343

44-
void fixup(QString &input) const
44+
void fixup(QString &input) const override
4545
{
4646
bool valid;
4747
CAmount val;
@@ -87,7 +87,7 @@ class AmountSpinBox: public QAbstractSpinBox
8787
m_max_amount = value;
8888
}
8989

90-
void stepBy(int steps)
90+
void stepBy(int steps) override
9191
{
9292
bool valid = false;
9393
CAmount val = value(&valid);
@@ -114,7 +114,7 @@ class AmountSpinBox: public QAbstractSpinBox
114114
singleStep = step;
115115
}
116116

117-
QSize minimumSizeHint() const
117+
QSize minimumSizeHint() const override
118118
{
119119
if(cachedMinimumSizeHint.isEmpty())
120120
{
@@ -175,7 +175,7 @@ class AmountSpinBox: public QAbstractSpinBox
175175
}
176176

177177
protected:
178-
bool event(QEvent *event)
178+
bool event(QEvent *event) override
179179
{
180180
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
181181
{
@@ -190,7 +190,7 @@ class AmountSpinBox: public QAbstractSpinBox
190190
return QAbstractSpinBox::event(event);
191191
}
192192

193-
StepEnabled stepEnabled() const
193+
StepEnabled stepEnabled() const override
194194
{
195195
if (isReadOnly()) // Disable steps when AmountSpinBox is read-only
196196
return StepNone;

src/qt/bitcoinamountfield.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BitcoinAmountField: public QWidget
7070

7171
protected:
7272
/** Intercept focus-in event and ',' key presses */
73-
bool eventFilter(QObject *object, QEvent *event);
73+
bool eventFilter(QObject *object, QEvent *event) override;
7474

7575
private:
7676
AmountSpinBox *amount;

src/qt/bitcoingui.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ class BitcoinGUI : public QMainWindow
9999
void unsubscribeFromCoreSignals();
100100

101101
protected:
102-
void changeEvent(QEvent *e);
103-
void closeEvent(QCloseEvent *event);
104-
void showEvent(QShowEvent *event);
105-
void dragEnterEvent(QDragEnterEvent *event);
106-
void dropEvent(QDropEvent *event);
107-
bool eventFilter(QObject *object, QEvent *event);
102+
void changeEvent(QEvent *e) override;
103+
void closeEvent(QCloseEvent *event) override;
104+
void showEvent(QShowEvent *event) override;
105+
void dragEnterEvent(QDragEnterEvent *event) override;
106+
void dropEvent(QDropEvent *event) override;
107+
bool eventFilter(QObject *object, QEvent *event) override;
108108

109109
private:
110110
interfaces::Node& m_node;
@@ -325,7 +325,7 @@ class UnitDisplayStatusBarControl : public QLabel
325325

326326
protected:
327327
/** So that it responds to left-button clicks */
328-
void mousePressEvent(QMouseEvent *event);
328+
void mousePressEvent(QMouseEvent *event) override;
329329

330330
private:
331331
OptionsModel *optionsModel;

0 commit comments

Comments
 (0)