Merge #18914: refactor: Apply override specifier consistently

d044e0ec7d refactor: Remove override for final overriders (Hennadii Stepanov)
1551cea2d5 refactor: Use override for non-final overriders (Hennadii Stepanov)

Pull request description:

  Two commits are split out from #16710 to make reviewing [easier](https://github.com/bitcoin/bitcoin/pull/16710#issuecomment-625760894).

  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 d044e0ec7d: consistent use of `override` prevents bugs + patch looks correct + Travis happy
  MarcoFalke:
    ACK d044e0ec7d, based on my understanding that adding `override` or `final` to a function must always be correct, unless it doesn't compile!?
  vasild:
    ACK d044e0ec7

Tree-SHA512: 245fd9b99b8b5cbf8694061f892cb3435f3378c97ebed9f9401ce86d21890211f2234bcc39c9f0f79a4d2806cb31bf8ce41a0f9c2acef4f3a2ac5beca6b077cf
This commit is contained in:
MarcoFalke 2020-05-11 13:34:01 -04:00
commit eb2ffbb7c1
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
37 changed files with 108 additions and 107 deletions

View file

@ -127,7 +127,7 @@ public:
::tableRPC.appendCommand(m_command.name, &m_command);
}
void disconnect() override final
void disconnect() final
{
if (m_wrapped_command) {
m_wrapped_command = nullptr;

View file

@ -35,7 +35,7 @@ public:
}
protected:
bool filterAcceptsRow(int row, const QModelIndex& parent) const
bool filterAcceptsRow(int row, const QModelIndex& parent) const override
{
auto model = sourceModel();
auto label = model->index(row, AddressTableModel::Label, parent);

View file

@ -45,7 +45,7 @@ public:
const QString &getReturnValue() const { return returnValue; }
public Q_SLOTS:
void done(int retval);
void done(int retval) override;
private:
Ui::AddressBookPage *ui;

View file

@ -52,14 +52,14 @@ public:
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
Qt::ItemFlags flags(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
/*@}*/
/* Add an address to the model.

View file

@ -32,7 +32,7 @@ public:
explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr);
~AskPassphraseDialog();
void accept();
void accept() override;
void setModel(WalletModel *model);
@ -49,8 +49,8 @@ private Q_SLOTS:
void toggleShowPassword(bool);
protected:
bool event(QEvent *event);
bool eventFilter(QObject *object, QEvent *event);
bool event(QEvent *event) override;
bool eventFilter(QObject *object, QEvent *event) override;
};
#endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H

View file

@ -56,16 +56,17 @@ public:
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void sort(int column, Qt::SortOrder order);
bool shouldShow();
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void sort(int column, Qt::SortOrder order) override;
/*@}*/
bool shouldShow();
public Q_SLOTS:
void refresh();

View file

@ -17,7 +17,7 @@ class BitcoinAddressEntryValidator : public QValidator
public:
explicit BitcoinAddressEntryValidator(QObject *parent);
State validate(QString &input, int &pos) const;
State validate(QString &input, int &pos) const override;
};
/** Bitcoin address widget validator, checks for a valid bitcoin address.
@ -29,7 +29,7 @@ class BitcoinAddressCheckValidator : public QValidator
public:
explicit BitcoinAddressCheckValidator(QObject *parent);
State validate(QString &input, int &pos) const;
State validate(QString &input, int &pos) const override;
};
#endif // BITCOIN_QT_BITCOINADDRESSVALIDATOR_H

View file

@ -31,7 +31,7 @@ public:
connect(lineEdit(), &QLineEdit::textEdited, this, &AmountSpinBox::valueChanged);
}
QValidator::State validate(QString &text, int &pos) const
QValidator::State validate(QString &text, int &pos) const override
{
if(text.isEmpty())
return QValidator::Intermediate;
@ -41,7 +41,7 @@ public:
return valid ? QValidator::Intermediate : QValidator::Invalid;
}
void fixup(QString &input) const
void fixup(QString &input) const override
{
bool valid;
CAmount val;
@ -87,7 +87,7 @@ public:
m_max_amount = value;
}
void stepBy(int steps)
void stepBy(int steps) override
{
bool valid = false;
CAmount val = value(&valid);
@ -114,7 +114,7 @@ public:
singleStep = step;
}
QSize minimumSizeHint() const
QSize minimumSizeHint() const override
{
if(cachedMinimumSizeHint.isEmpty())
{
@ -175,7 +175,7 @@ private:
}
protected:
bool event(QEvent *event)
bool event(QEvent *event) override
{
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
{
@ -190,7 +190,7 @@ protected:
return QAbstractSpinBox::event(event);
}
StepEnabled stepEnabled() const
StepEnabled stepEnabled() const override
{
if (isReadOnly()) // Disable steps when AmountSpinBox is read-only
return StepNone;

View file

@ -70,7 +70,7 @@ Q_SIGNALS:
protected:
/** Intercept focus-in event and ',' key presses */
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
private:
AmountSpinBox *amount;

View file

@ -99,12 +99,12 @@ public:
void unsubscribeFromCoreSignals();
protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
bool eventFilter(QObject *object, QEvent *event);
void changeEvent(QEvent *e) override;
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
bool eventFilter(QObject *object, QEvent *event) override;
private:
interfaces::Node& m_node;
@ -325,7 +325,7 @@ public:
protected:
/** So that it responds to left-button clicks */
void mousePressEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) override;
private:
OptionsModel *optionsModel;

View file

@ -90,8 +90,8 @@ public:
/** Unit identifier */
UnitRole = Qt::UserRole
};
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
///@}
static QString removeSpaces(QString text)

View file

@ -34,7 +34,7 @@ public:
explicit CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {}
explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
bool operator<(const QTreeWidgetItem &other) const;
bool operator<(const QTreeWidgetItem &other) const override;
};

View file

@ -16,7 +16,7 @@ public:
explicit CoinControlTreeWidget(QWidget *parent = nullptr);
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent *event) override;
};
#endif // BITCOIN_QT_COINCONTROLTREEWIDGET_H

View file

@ -40,7 +40,7 @@ public:
void setAddress(const QString &address);
public Q_SLOTS:
void accept();
void accept() override;
private:
bool saveCurrentRow();

View file

@ -145,7 +145,7 @@ namespace GUIUtil
explicit ToolTipToRichTextFilter(int size_threshold, QObject *parent = nullptr);
protected:
bool eventFilter(QObject *obj, QEvent *evt);
bool eventFilter(QObject *obj, QEvent *evt) override;
private:
int size_threshold;
@ -227,7 +227,7 @@ namespace GUIUtil
*/
void clicked(const QPoint& point);
protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event) override;
};
class ClickableProgressBar : public QProgressBar
@ -240,7 +240,7 @@ namespace GUIUtil
*/
void clicked(const QPoint& point);
protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event) override;
};
typedef ClickableProgressBar ProgressBar;
@ -255,7 +255,7 @@ namespace GUIUtil
void keyEscapePressed();
private:
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
};
// Fix known bugs in QProgressDialog class.

View file

@ -35,8 +35,8 @@ public Q_SLOTS:
bool isLayerVisible() const { return layerIsVisible; }
protected:
bool eventFilter(QObject * obj, QEvent * ev);
bool event(QEvent* ev);
bool eventFilter(QObject * obj, QEvent * ev) override;
bool event(QEvent* ev) override;
private:
Ui::ModalOverlay *ui;

View file

@ -22,7 +22,7 @@ public:
QString getURI();
protected Q_SLOTS:
void accept();
void accept() override;
private:
Ui::OpenURIDialog *ui;

View file

@ -28,7 +28,7 @@ class ProxyAddressValidator : public QValidator
public:
explicit ProxyAddressValidator(QObject *parent);
State validate(QString &input, int &pos) const;
State validate(QString &input, int &pos) const override;
};
/** Preferences dialog. */

View file

@ -68,9 +68,9 @@ public:
void Init(bool resetSettings = false);
void Reset();
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void setDisplayUnit(const QVariant &value);

View file

@ -35,7 +35,7 @@ public:
}
inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
const QModelIndex &index ) const override
{
painter->save();
@ -99,7 +99,7 @@ public:
painter->restore();
}
inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
return QSize(DECORATION_SIZE, DECORATION_SIZE);
}

View file

@ -98,7 +98,7 @@ private Q_SLOTS:
protected:
// Constructor registers this on the parent QApplication to
// receive QEvent::FileOpen and QEvent:Drop events
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
private:
bool saveURIs; // true during startup

View file

@ -68,13 +68,13 @@ public:
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void sort(int column, Qt::SortOrder order);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void sort(int column, Qt::SortOrder order) override;
/*@}*/
public Q_SLOTS:

View file

@ -35,8 +35,8 @@ public Q_SLOTS:
void copyImage();
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void contextMenuEvent(QContextMenuEvent *event) override;
private:
QMenu *contextMenu;

View file

@ -21,8 +21,8 @@ public:
bool isValid();
protected:
void focusInEvent(QFocusEvent *evt);
void focusOutEvent(QFocusEvent *evt);
void focusInEvent(QFocusEvent *evt) override;
void focusOutEvent(QFocusEvent *evt) override;
private:
bool valid;

View file

@ -46,11 +46,11 @@ public:
public Q_SLOTS:
void clear();
void reject();
void accept();
void reject() override;
void accept() override;
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent *event) override;
private:
Ui::ReceiveCoinsDialog *ui;
@ -61,7 +61,7 @@ private:
QModelIndex selectedRow();
void copyColumnToClipboard(int column);
virtual void resizeEvent(QResizeEvent *event);
virtual void resizeEvent(QResizeEvent *event) override;
private Q_SLOTS:
void on_receiveButton_clicked();

View file

@ -73,14 +73,15 @@ public:
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
Qt::ItemFlags flags(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
/*@}*/
const RecentRequestEntry &entry(int row) const { return list[row]; }
@ -89,7 +90,6 @@ public:
void addNewRequest(RecentRequestEntry &recipient);
public Q_SLOTS:
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void updateDisplayUnit();
private:

View file

@ -115,8 +115,8 @@ class QtRPCTimerInterface: public RPCTimerInterface
{
public:
~QtRPCTimerInterface() {}
const char *Name() { return "Qt"; }
RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis)
const char *Name() override { return "Qt"; }
RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis) override
{
return new QtRPCTimerBase(func, millis);
}

View file

@ -71,8 +71,8 @@ public:
QKeySequence tabShortcut(TabTypes tab_type) const;
protected:
virtual bool eventFilter(QObject* obj, QEvent *event);
void keyPressEvent(QKeyEvent *);
virtual bool eventFilter(QObject* obj, QEvent *event) override;
void keyPressEvent(QKeyEvent *) override;
private Q_SLOTS:
void on_lineEdit_returnPressed();
@ -83,9 +83,9 @@ private Q_SLOTS:
void on_sldGraphRange_valueChanged(int value);
/** update traffic statistics */
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);
void hideEvent(QHideEvent *event);
void resizeEvent(QResizeEvent *event) override;
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
/** Show custom context menu on Peers tab */
void showPeersTableContextMenu(const QPoint& point);
/** Show custom context menu on Bans tab */

View file

@ -47,8 +47,8 @@ public:
public Q_SLOTS:
void clear();
void reject();
void accept();
void reject() override;
void accept() override;
SendCoinsEntry *addEntry();
void updateTabsAndLabels();
void setBalance(const interfaces::WalletBalances& balances);
@ -112,7 +112,7 @@ class SendConfirmationDialog : public QMessageBox
public:
SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text = "", const QString& detailed_text = "", int secDelay = SEND_CONFIRM_DELAY, const QString& confirmText = "Send", QWidget* parent = nullptr);
int exec();
int exec() override;
private Q_SLOTS:
void countDown();

View file

@ -30,7 +30,7 @@ public:
void showTab_VM(bool fShow);
protected:
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
private:
Ui::SignVerifyMessageDialog *ui;

View file

@ -32,8 +32,8 @@ public:
~SplashScreen();
protected:
void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
void paintEvent(QPaintEvent *event) override;
void closeEvent(QCloseEvent *event) override;
public Q_SLOTS:
/** Hide the splash screen window and schedule the splash screen object for deletion */
@ -43,7 +43,7 @@ public Q_SLOTS:
void showMessage(const QString &message, int alignment, const QColor &color);
protected:
bool eventFilter(QObject * obj, QEvent * ev);
bool eventFilter(QObject * obj, QEvent * ev) override;
private:
/** Connect core signals to splash screen */

View file

@ -25,7 +25,7 @@ public:
int getGraphRangeMins() const;
protected:
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
public Q_SLOTS:
void updateRates();

View file

@ -49,10 +49,10 @@ public:
/** Set whether to show conflicted transactions. */
void setShowInactive(bool showInactive);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
protected:
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;
private:
QDateTime dateFrom;

View file

@ -76,11 +76,11 @@ public:
RawDecorationRole,
};
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
private:

View file

@ -82,9 +82,9 @@ private:
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
virtual void resizeEvent(QResizeEvent* event);
virtual void resizeEvent(QResizeEvent* event) override;
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
private Q_SLOTS:
void contextualMenu(const QPoint &);

View file

@ -51,7 +51,7 @@ public:
static QWidget* showShutdownWindow(QMainWindow* window);
protected:
void closeEvent(QCloseEvent *event);
void closeEvent(QCloseEvent *event) override;
};
#endif // BITCOIN_QT_UTILITYDIALOG_H

View file

@ -481,7 +481,7 @@ public:
return AddChecksum(ret);
}
bool ToPrivateString(const SigningProvider& arg, std::string& out) const override final
bool ToPrivateString(const SigningProvider& arg, std::string& out) const final
{
bool ret = ToStringHelper(&arg, out, true);
out = AddChecksum(out);