Skip to content

Commit

Permalink
gui: Add thread to run background activity in WalletController
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Feb 4, 2019
1 parent 6c49a55 commit be82dea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ WalletController::WalletController(interfaces::Node& node, const PlatformStyle*
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.getWallets()) {
getOrCreateWallet(std::move(wallet));
}

m_activity_thread.start();
}

// Not using the default destructor because not all member types definitions are
// available in the header, just forward declared.
WalletController::~WalletController() {}
WalletController::~WalletController()
{
m_activity_thread.quit();
m_activity_thread.wait();
}

std::vector<WalletModel*> WalletController::getWallets() const
{
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>

#include <QMutex>
#include <QThread>

class OptionsModel;
class PlatformStyle;
Expand Down Expand Up @@ -51,6 +52,7 @@ private Q_SLOTS:
void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction);

private:
QThread m_activity_thread;
interfaces::Node& m_node;
const PlatformStyle* const m_platform_style;
OptionsModel* const m_options_model;
Expand Down

0 comments on commit be82dea

Please sign in to comment.