From 71f4433a394ed1f08f995a643f0aae205e8587c5 Mon Sep 17 00:00:00 2001 From: adityapk Date: Thu, 8 Nov 2018 14:43:10 -0800 Subject: [PATCH] cleanup --- src/connection.cpp | 4 ++-- src/rpc.cpp | 7 +++++-- src/senttxstore.cpp | 4 ++-- src/settings.cpp | 5 +---- src/turnstile.cpp | 8 ++------ src/turnstile.h | 1 - 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 527d517..14e1841 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -265,7 +265,7 @@ bool ConnectionLoader::startEmbeddedZcashd() { void ConnectionLoader::doManualConnect() { auto config = loadFromSettings(); - if (config.get() == nullptr) { + if (!config) { // Nothing configured, show an error QString explanation = QString() % "A manual connection was requested, but the settings are not configured.\n\n" @@ -569,4 +569,4 @@ void Connection::showTxError(const QString& error) { */ void Connection::shutdown() { shutdownInProgress = true; -} \ No newline at end of file +} diff --git a/src/rpc.cpp b/src/rpc.cpp index 20b521e..e8c2077 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -837,7 +837,7 @@ void RPC::refreshZECPrice() { } for (const json& item : parsed.get()) { - if (item["symbol"].get().compare("ZEC") == 0) { + if (item["symbol"].get() == "ZEC") { QString price = QString::fromStdString(item["price_usd"].get()); qDebug() << "ZEC Price=" << price; Settings::getInstance()->setZECPrice(price.toDouble()); @@ -881,8 +881,11 @@ void RPC::shutdownZcashd() { // We capture by reference all the local variables because of the d.exec() // below, which blocks this function until we exit. + int waitCount = 0; QObject::connect(&waiter, &QTimer::timeout, [&] () { - if (ezcashd->atEnd() && ezcashd->processId() == 0) { + waitCount++; + if ((ezcashd->atEnd() && ezcashd->processId() == 0) || + waitCount > 30) { qDebug() << "Ended"; waiter.stop(); QTimer::singleShot(1000, [&]() { d.accept(); }); diff --git a/src/senttxstore.cpp b/src/senttxstore.cpp index f5d587d..bb77a8b 100644 --- a/src/senttxstore.cpp +++ b/src/senttxstore.cpp @@ -31,7 +31,7 @@ QList SentTxStore::readSentTxFile() { QJsonDocument jsonDoc; data.open(QFile::ReadOnly); - jsonDoc = QJsonDocument().fromJson(data.readAll()); + jsonDoc = QJsonDocument::fromJson(data.readAll()); data.close(); QList items; @@ -87,7 +87,7 @@ void SentTxStore::addToSentTx(Tx tx, QString txid) { QJsonObject txItem; txItem["type"] = "sent"; txItem["from"] = tx.fromAddr; - txItem["datetime"] = QDateTime().currentMSecsSinceEpoch() / (qint64)1000; + txItem["datetime"] = QDateTime::currentMSecsSinceEpoch() / (qint64)1000; txItem["address"] = QString(); // The sent address is blank, to be consistent with t-Addr sent behaviour txItem["txid"] = txid; txItem["amount"] = -totalAmount; diff --git a/src/settings.cpp b/src/settings.cpp index fa7fa9a..38fee88 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -5,9 +5,6 @@ Settings* Settings::instance = nullptr; -Settings::~Settings() { -} - bool Settings::getSaveZtxs() { // Load from the QT Settings. return QSettings().value("options/savesenttx", true).toBool(); @@ -122,4 +119,4 @@ QString Settings::getZECUSDDisplayFormat(double bal) { return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")"; else return getZECDisplayFormat(bal); -} \ No newline at end of file +} diff --git a/src/turnstile.cpp b/src/turnstile.cpp index fb2211f..64ec6e0 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -14,8 +14,6 @@ Turnstile::Turnstile(RPC* _rpc, MainWindow* mainwindow) { this->mainwindow = mainwindow; } -Turnstile::~Turnstile() { -} void printPlan(QList plan) { for (auto item : plan) { @@ -118,7 +116,7 @@ void Turnstile::planMigration(QString zaddr, QString destAddr, int numsplits, in // The first migration is shifted to the current block, so the user sees something // happening immediately - if (migItems.size() == 0) { + if (migItems.empty()) { // Show error and abort QMessageBox::warning(mainwindow, "Locked funds", @@ -220,9 +218,7 @@ Turnstile::getNextStep(QList& plan) { bool Turnstile::isMigrationPresent() { auto plan = readMigrationPlan(); - if (plan.isEmpty()) return false; - - return true; + return !plan.isEmpty(); } ProgressReport Turnstile::getPlanProgress() { diff --git a/src/turnstile.h b/src/turnstile.h index a73af50..aba1a3e 100644 --- a/src/turnstile.h +++ b/src/turnstile.h @@ -39,7 +39,6 @@ class Turnstile { public: Turnstile(RPC* _rpc, MainWindow* mainwindow); - ~Turnstile(); void planMigration(QString zaddr, QString destAddr, int splits, int numBlocks); QList splitAmount(double amount, int parts);