]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Don't allow manually storing wallet during synchronization
authortobtoht <thotbot@protonmail.com>
Sat, 14 Aug 2021 14:53:22 +0000 (16:53 +0200)
committertobtoht <thotbot@protonmail.com>
Wed, 15 Sep 2021 21:44:51 +0000 (23:44 +0200)
src/MainWindow.cpp
src/MainWindow.h

index c6121649c9c7ac7cba8df5251ceaf64848ee144f..914e04470dabbbd7e15aa92c74b63c32d00111c1 100644 (file)
@@ -236,7 +236,7 @@ void MainWindow::initMenu() {
     connect(ui->actionViewOnly,     &QAction::triggered, this, &MainWindow::showViewOnlyDialog);
 
     // [Wallet] -> [Advanced]
-    connect(ui->actionStore_wallet,          &QAction::triggered, [this]{m_ctx->wallet->store();});
+    connect(ui->actionStore_wallet,          &QAction::triggered, this, &MainWindow::tryStoreWallet);
     connect(ui->actionUpdate_balance,        &QAction::triggered, [this]{m_ctx->updateBalance();});
     connect(ui->actionRefresh_tabs,          &QAction::triggered, [this]{m_ctx->refreshModels();});
     connect(ui->actionRescan_spent,          &QAction::triggered, this, &MainWindow::rescanSpent);
@@ -530,6 +530,16 @@ void MainWindow::setStatusText(const QString &text, bool override, int timeout)
     }
 }
 
+void MainWindow::tryStoreWallet() {
+    if (m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus::ConnectionStatus_Synchronizing) {
+        QMessageBox::warning(this, "Save wallet", "Unable to save wallet during synchronization.\n\n"
+                                                  "Wait until synchronization is finished and try again.");
+        return;
+    }
+
+    m_ctx->wallet->store();
+}
+
 void MainWindow::onSynchronized() {
     this->updateNetStats();
     this->setStatusText("Synchronized");
index 6def9dddf5412a9cf7ca836e4500e3e57de3f032..883329d04015a8f6c7c4823bdaa056e5e6ac15eb 100644 (file)
@@ -180,6 +180,7 @@ private slots:
     void onUpdatesAvailable(const QJsonObject &updates);
     void toggleSearchbar(bool enabled);
     void onSetStatusText(const QString &text);
+    void tryStoreWallet();
 
 private:
     friend WindowManager;