mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-28 18:56:32 +02:00
WalletManager: fix possible race
This commit is contained in:
parent
9dbbd4c9bc
commit
cb3281dee8
@ -64,13 +64,14 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password
|
|||||||
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
||||||
path, password, testnet);
|
path, password, testnet);
|
||||||
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
QFuture<Wallet*> future = watcher->future();
|
QFuture<Wallet*> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit walletOpened(future.result());
|
emit walletOpened(future.result());
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,7 +122,6 @@ void WalletManager::closeWalletAsync()
|
|||||||
{
|
{
|
||||||
QFuture<QString> future = QtConcurrent::run(this, &WalletManager::closeWallet);
|
QFuture<QString> future = QtConcurrent::run(this, &WalletManager::closeWallet);
|
||||||
QFutureWatcher<QString> * watcher = new QFutureWatcher<QString>();
|
QFutureWatcher<QString> * watcher = new QFutureWatcher<QString>();
|
||||||
watcher->setFuture(future);
|
|
||||||
|
|
||||||
connect(watcher, &QFutureWatcher<QString>::finished,
|
connect(watcher, &QFutureWatcher<QString>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
@ -129,6 +129,7 @@ void WalletManager::closeWalletAsync()
|
|||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit walletClosed(future.result());
|
emit walletClosed(future.result());
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletManager::walletExists(const QString &path) const
|
bool WalletManager::walletExists(const QString &path) const
|
||||||
|
Loading…
Reference in New Issue
Block a user