From fc261502d15423c611c11bf778a58224bfddac65 Mon Sep 17 00:00:00 2001 From: selsta Date: Sat, 6 Aug 2022 21:58:21 +0200 Subject: [PATCH] libwalletqt: refresh once on wallet opening Co-authored-by: tobtoht --- src/libwalletqt/Wallet.cpp | 5 ++++- src/libwalletqt/Wallet.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index cec8378e..14d2eab2 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -545,6 +545,7 @@ bool Wallet::refresh(bool historyAndSubaddresses /* = true */) void Wallet::startRefresh() { m_refreshEnabled = true; + m_refreshNow = true; } void Wallet::pauseRefresh() @@ -1142,6 +1143,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent) , m_subaddressModel(nullptr) , m_subaddressAccount(new SubaddressAccount(m_walletImpl->subaddressAccount(), this)) , m_subaddressAccountModel(nullptr) + , m_refreshNow(false) , m_refreshEnabled(false) , m_refreshing(false) , m_scheduler(this) @@ -1195,10 +1197,11 @@ void Wallet::startRefreshThread() { const auto now = std::chrono::steady_clock::now(); const auto elapsed = now - last; - if (elapsed >= refreshInterval) + if (elapsed >= refreshInterval || m_refreshNow) { refresh(false); last = std::chrono::steady_clock::now(); + m_refreshNow = false; } } diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 039417d8..68d4cdad 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -473,6 +473,7 @@ private: QString m_daemonPassword; QString m_proxyAddress; mutable QMutex m_proxyMutex; + std::atomic m_refreshNow; std::atomic m_refreshEnabled; std::atomic m_refreshing; WalletListenerImpl *m_walletListener;