mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Merge pull request 'Bugfix: fix wallet closing issues by partially reverting #63' (#84) from tobtoht/feather:duplicate_wizard into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/84
This commit is contained in:
commit
497567e61f
3 changed files with 21 additions and 91 deletions
|
@ -3,10 +3,6 @@
|
|||
|
||||
#include "Wallet.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <stdexcept>
|
||||
#include <thread>
|
||||
|
||||
#include "PendingTransaction.h"
|
||||
#include "UnsignedTransaction.h"
|
||||
#include "TransactionHistory.h"
|
||||
|
@ -32,8 +28,6 @@
|
|||
#include <QVector>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include "utils/ScopeGuard.h"
|
||||
|
||||
namespace {
|
||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 5;
|
||||
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 30;
|
||||
|
@ -107,19 +101,6 @@ bool Wallet::disconnected() const
|
|||
return m_disconnected;
|
||||
}
|
||||
|
||||
bool Wallet::refreshing() const
|
||||
{
|
||||
return m_refreshing;
|
||||
}
|
||||
|
||||
void Wallet::refreshingSet(bool value)
|
||||
{
|
||||
if (m_refreshing.exchange(value) != value)
|
||||
{
|
||||
emit refreshingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Wallet::setConnectionStatus(ConnectionStatus value)
|
||||
{
|
||||
if (m_connectionStatus == value)
|
||||
|
@ -264,7 +245,7 @@ void Wallet::initAsync(
|
|||
emit walletCreationHeightChanged();
|
||||
qDebug() << "init async finished - starting refresh";
|
||||
connected(true);
|
||||
startRefresh();
|
||||
m_walletImpl->startRefresh();
|
||||
}
|
||||
});
|
||||
if (future.first)
|
||||
|
@ -475,36 +456,20 @@ bool Wallet::importOutputs(const QString& path) {
|
|||
return m_walletImpl->importOutputs(path.toStdString());
|
||||
}
|
||||
|
||||
bool Wallet::refresh(bool historyAndSubaddresses /* = true */)
|
||||
bool Wallet::refresh()
|
||||
{
|
||||
refreshingSet(true);
|
||||
const auto cleanup = sg::make_scope_guard([this]() noexcept {
|
||||
refreshingSet(false);
|
||||
});
|
||||
|
||||
{
|
||||
QMutexLocker locker(&m_asyncMutex);
|
||||
|
||||
bool result = m_walletImpl->refresh();
|
||||
if (historyAndSubaddresses)
|
||||
{
|
||||
m_history->refresh(currentSubaddressAccount());
|
||||
m_subaddress->refresh(currentSubaddressAccount());
|
||||
m_subaddressAccount->getAll();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
qDebug() << "refresh async";
|
||||
m_walletImpl->refreshAsync();
|
||||
}
|
||||
|
||||
void Wallet::startRefresh()
|
||||
void Wallet::startRefresh() const
|
||||
{
|
||||
m_refreshEnabled = true;
|
||||
m_walletImpl->startRefresh();
|
||||
}
|
||||
|
||||
void Wallet::pauseRefresh()
|
||||
void Wallet::pauseRefresh() const
|
||||
{
|
||||
m_refreshEnabled = false;
|
||||
m_walletImpl->pauseRefresh();
|
||||
}
|
||||
|
||||
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QString &payment_id,
|
||||
|
@ -1083,8 +1048,6 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
|||
, m_subaddressAccount(nullptr)
|
||||
, m_subaddressAccountModel(nullptr)
|
||||
, m_coinsModel(nullptr)
|
||||
, m_refreshEnabled(false)
|
||||
, m_refreshing(false)
|
||||
, m_scheduler(this)
|
||||
{
|
||||
m_history = new TransactionHistory(m_walletImpl->history(), this);
|
||||
|
@ -1103,8 +1066,6 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
|||
m_connectionStatusRunning = false;
|
||||
m_daemonUsername = "";
|
||||
m_daemonPassword = "";
|
||||
|
||||
startRefreshThread();
|
||||
}
|
||||
|
||||
Wallet::~Wallet()
|
||||
|
@ -1129,42 +1090,14 @@ Wallet::~Wallet()
|
|||
//Monero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
|
||||
if(status() == Status_Critical)
|
||||
qDebug("Not storing wallet cache");
|
||||
else if( m_walletImpl->store(""))
|
||||
qDebug("Wallet cache stored successfully");
|
||||
else
|
||||
qDebug("Error storing wallet cache");
|
||||
// Don't store on wallet close for now
|
||||
// else if( m_walletImpl->store(""))
|
||||
// qDebug("Wallet cache stored successfully");
|
||||
// else
|
||||
// qDebug("Error storing wallet cache");
|
||||
delete m_walletImpl;
|
||||
m_walletImpl = NULL;
|
||||
delete m_walletListener;
|
||||
m_walletListener = NULL;
|
||||
qDebug("m_walletImpl deleted");
|
||||
}
|
||||
|
||||
void Wallet::startRefreshThread()
|
||||
{
|
||||
const auto future = m_scheduler.run([this] {
|
||||
static constexpr const size_t refreshIntervalSec = 10;
|
||||
static constexpr const size_t intervalResolutionMs = 100;
|
||||
|
||||
auto last = std::chrono::steady_clock::now();
|
||||
while (!m_scheduler.stopping())
|
||||
{
|
||||
if (m_refreshEnabled)
|
||||
{
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
const auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - last).count();
|
||||
if (elapsed >= refreshIntervalSec)
|
||||
{
|
||||
refresh(false);
|
||||
last = std::chrono::steady_clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(intervalResolutionMs));
|
||||
}
|
||||
});
|
||||
if (!future.first)
|
||||
{
|
||||
throw std::runtime_error("failed to start auto refresh thread");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ class Wallet : public QObject, public PassprasePrompter
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool disconnected READ disconnected NOTIFY disconnectedChanged)
|
||||
Q_PROPERTY(bool refreshing READ refreshing NOTIFY refreshingChanged)
|
||||
Q_PROPERTY(QString seed READ getSeed)
|
||||
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
||||
Q_PROPERTY(Status status READ status)
|
||||
|
@ -200,11 +199,11 @@ public:
|
|||
Q_INVOKABLE bool importOutputs(const QString& path);
|
||||
|
||||
//! refreshes the wallet
|
||||
Q_INVOKABLE bool refresh(bool historyAndSubaddresses = true);
|
||||
Q_INVOKABLE bool refresh();
|
||||
|
||||
// pause/resume refresh
|
||||
Q_INVOKABLE void startRefresh();
|
||||
Q_INVOKABLE void pauseRefresh();
|
||||
Q_INVOKABLE void startRefresh() const;
|
||||
Q_INVOKABLE void pauseRefresh() const;
|
||||
|
||||
//! returns current wallet's block height
|
||||
//! (can be less than daemon's blockchain height when wallet sync in progress)
|
||||
|
@ -406,7 +405,6 @@ signals:
|
|||
void currentSubaddressAccountChanged() const;
|
||||
void disconnectedChanged() const;
|
||||
void proxyAddressChanged() const;
|
||||
void refreshingChanged() const;
|
||||
|
||||
private:
|
||||
Wallet(QObject * parent = nullptr);
|
||||
|
@ -424,12 +422,9 @@ private:
|
|||
const QString& proxyAddress);
|
||||
|
||||
bool disconnected() const;
|
||||
bool refreshing() const;
|
||||
void refreshingSet(bool value);
|
||||
void setConnectionStatus(ConnectionStatus value);
|
||||
QString getProxyAddress() const;
|
||||
void setProxyAddress(QString address);
|
||||
void startRefreshThread();
|
||||
|
||||
private:
|
||||
friend class WalletManager;
|
||||
|
|
|
@ -505,7 +505,11 @@ WalletWizard *MainWindow::createWizard(WalletWizard::Page startPage){
|
|||
|
||||
void MainWindow::showWizard(WalletWizard::Page startPage) {
|
||||
this->setEnabled(false);
|
||||
m_wizard = this->createWizard(startPage);
|
||||
if (m_wizard == nullptr)
|
||||
m_wizard = this->createWizard(startPage);
|
||||
m_wizard->setStartId(startPage);
|
||||
m_wizard->restart();
|
||||
m_wizard->setEnabled(true);
|
||||
m_wizard->show();
|
||||
}
|
||||
|
||||
|
@ -558,8 +562,6 @@ void MainWindow::onWalletOpened() {
|
|||
qDebug() << Q_FUNC_INFO;
|
||||
if(m_wizard != nullptr) {
|
||||
m_wizard->hide();
|
||||
m_wizard->disconnect();
|
||||
m_wizard->deleteLater();
|
||||
}
|
||||
|
||||
this->raise();
|
||||
|
|
Loading…
Reference in a new issue