Skip to content

Commit

Permalink
Merge #2529: [GUI][BugFix] Masternodes screen, fix impossibility to s…
Browse files Browse the repository at this point in the history
…tart Masternodes

85b926e [GUI] MasternodesWidget Fix: missing walletModel in mnmodel constructor. (furszy)

Pull request description:

  Fix impossibility to start Masternodes using the GUI.

  This was introduced by beb1cf6 (curiously enough, no one noticed it up until now..), the `walletModel` is provided to the widget in `loadWalletModel`, so it can't be used in the `MasternodesWidget` constructor to construct the `mnmodel` object.

ACKs for top commit:
  Fuzzbawls:
    ACK 85b926e
  random-zebra:
    nice catch. We need to backport this to the 5.3 branch. utACK 85b926e and merging...

Tree-SHA512: 5cbceadd4d1c622ec38608ba48aa96f36c9b25fd707fbd30591ab0a8a3ba0d10509185d5988110b33ae22ac51e1ab78b341dc0a8ba815770a685c9fabb97a5b4
  • Loading branch information
random-zebra committed Aug 25, 2021
2 parents 57cb997 + 85b926e commit 8ac28b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/qt/pivx/masternodeswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ MasterNodesWidget::MasterNodesWidget(PIVXGUI *parent) :
new MNHolder(isLightTheme()),
this
);
mnModel = new MNModel(this, walletModel);

this->setStyleSheet(parent->styleSheet());

Expand Down Expand Up @@ -142,6 +141,7 @@ void MasterNodesWidget::hideEvent(QHideEvent *event)
void MasterNodesWidget::loadWalletModel()
{
if (walletModel) {
mnModel = new MNModel(this, walletModel);
ui->listMn->setModel(mnModel);
ui->listMn->setModelColumn(AddressTableModel::Label);
updateListState();
Expand Down Expand Up @@ -216,12 +216,12 @@ void MasterNodesWidget::onEditMNClicked()
}
}

void MasterNodesWidget::startAlias(QString strAlias)
void MasterNodesWidget::startAlias(const QString& strAlias)
{
QString strStatusHtml;
strStatusHtml += "Alias: " + strAlias + " ";

for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
for (const auto& mne : masternodeConfig.getEntries()) {
if (mne.getAlias() == strAlias.toStdString()) {
std::string strError;
strStatusHtml += (!startMN(mne, strError)) ? ("failed to start.\nError: " + QString::fromStdString(strError)) : "successfully started.";
Expand All @@ -232,7 +232,7 @@ void MasterNodesWidget::startAlias(QString strAlias)
updateModelAndInform(strStatusHtml);
}

void MasterNodesWidget::updateModelAndInform(QString informText)
void MasterNodesWidget::updateModelAndInform(const QString& informText)
{
mnModel->updateMNList();
inform(informText);
Expand Down Expand Up @@ -276,7 +276,7 @@ bool MasterNodesWidget::startAll(QString& failText, bool onlyMissing)
{
int amountOfMnFailed = 0;
int amountOfMnStarted = 0;
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
for (const auto& mne : masternodeConfig.getEntries()) {
// Check for missing only
QString mnAlias = QString::fromStdString(mne.getAlias());
if (onlyMissing && !mnModel->isMNInactive(mnAlias)) {
Expand Down
4 changes: 2 additions & 2 deletions src/qt/pivx/masternodeswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private Q_SLOTS:
void onDeleteMNClicked();
void onInfoMNClicked();
void updateListState();
void updateModelAndInform(QString informText);
void updateModelAndInform(const QString& informText);

private:
Ui::MasterNodesWidget *ui;
Expand All @@ -65,7 +65,7 @@ private Q_SLOTS:
std::atomic<bool> isLoading;

bool checkMNsNetwork();
void startAlias(QString strAlias);
void startAlias(const QString& strAlias);
bool startAll(QString& failedMN, bool onlyMissing);
bool startMN(const CMasternodeConfig::CMasternodeEntry& mne, std::string& strError);
};
Expand Down

0 comments on commit 8ac28b8

Please sign in to comment.