From cb3281dee80edd9f811bdb80be3e3df7555a2daf Mon Sep 17 00:00:00 2001 From: Jaquee Date: Mon, 30 Jan 2017 18:22:59 +0100 Subject: [PATCH] WalletManager: fix possible race --- src/libwalletqt/WalletManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index ec03610d..df0ffdbd 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -64,13 +64,14 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password QFuture future = QtConcurrent::run(this, &WalletManager::openWallet, path, password, testnet); QFutureWatcher * watcher = new QFutureWatcher(); - watcher->setFuture(future); + connect(watcher, &QFutureWatcher::finished, this, [this, watcher]() { QFuture future = watcher->future(); watcher->deleteLater(); emit walletOpened(future.result()); }); + watcher->setFuture(future); } @@ -121,7 +122,6 @@ void WalletManager::closeWalletAsync() { QFuture future = QtConcurrent::run(this, &WalletManager::closeWallet); QFutureWatcher * watcher = new QFutureWatcher(); - watcher->setFuture(future); connect(watcher, &QFutureWatcher::finished, this, [this, watcher]() { @@ -129,6 +129,7 @@ void WalletManager::closeWalletAsync() watcher->deleteLater(); emit walletClosed(future.result()); }); + watcher->setFuture(future); } bool WalletManager::walletExists(const QString &path) const