Initialize variables previously neither defined where defined nor in constructor:
editStatusautoCompleter
Also; initialize non-static class members where they are defined in accordance with developer notes.
Initialize variables previously neither defined where defined nor in constructor:
editStatusautoCompleterAlso; initialize non-static class members where they are defined in accordance with developer notes.
80 | @@ -81,10 +81,10 @@ class AddressTableModel : public QAbstractTableModel 81 | OutputType GetDefaultAddressType() const; 82 | 83 | private: 84 | - WalletModel *walletModel; 85 | - AddressTablePriv *priv; 86 | + WalletModel *walletModel = nullptr;
walletModel and priv are initialized in constructor:
https://github.com/bitcoin/bitcoin/blob/727175a08dffcb5f18f8faac562ab54f89e5f36e/src/qt/addresstablemodel.cpp#L162
@promag See the pull request description – it was only editStatus and autoCompleter that were previously neither initialized where defined nor in constructor. The other ones:
Also; initialize non-static class members where they are defined in accordance with developer notes.
walletModel is initialized in constructor, why this? Maybe change here to
WalletModel* const walletModel;
so it only compiles if initialized in constructor.
144 | @@ -145,18 +145,18 @@ public Q_SLOTS: 145 | }; 146 | 147 | interfaces::Node& m_node; 148 | - Ui::RPCConsole *ui; 149 | - ClientModel *clientModel; 150 | + Ui::RPCConsole *ui = nullptr;
@promag See the pull request description – it was only editStatus and autoCompleter that were previously neither initialized where defined nor in constructor. The other ones:
Also; initialize non-static class members where they are defined in accordance with developer notes.
Same as above
Ui::RPCConsole* const ui;
Makes sense and code looks better afterwards. utACK f131872653dadafd9af8bec255dfd2bddd75a471
In which case you can remove the redundant initialization from the constructor, no?
I meant to say what @MarcoFalke asked.
@promag @MarcoFalke Is this the suggested change? :-)
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 1e3acd7..b6ecd40 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -159,7 +159,7 @@ public:
};
AddressTableModel::AddressTableModel(WalletModel *parent) :
- QAbstractTableModel(parent),walletModel(parent),priv(0)
+ QAbstractTableModel(parent), walletModel(parent)
{
columns << tr("Label") << tr("Address");
priv = new AddressTablePriv(this);
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 5122bab..7924840 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -455,12 +455,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
QWidget(parent),
m_node(node),
ui(new Ui::RPCConsole),
- clientModel(0),
- historyPtr(0),
- platformStyle(_platformStyle),
- peersTableContextMenu(0),
- banTableContextMenu(0),
- consoleFontSize(0)
+ platformStyle(_platformStyle)
{
ui->setupUi(this);
QSettings settings;
Yes.
Updated. Now including @MarcoFalke and @promag's suggestions. Please re-review :-)
Anyone willing to re-review? @laanwj, would you mind reviewing? :-)
Feels icky to have uninitialized variables laying around :-)
158 | - RPCTimerInterface *rpcTimerInterface; 159 | - QMenu *peersTableContextMenu; 160 | - QMenu *banTableContextMenu; 161 | - int consoleFontSize; 162 | - QCompleter *autoCompleter; 163 | + const PlatformStyle *platformStyle = nullptr;
Same as above
const PlatformStyle* const platformStyle;
IMO if a member is initialized in the constructor with a non const expression then it should not be initialized where it's defined.
@promag Good point. Updated – please re-review! :-)
utACK 3fdc5fe.
utACK 3fdc5fee1864c759bceabaa61e104f954b9d1180