gui: Add thread to run background activity in WalletController

This commit is contained in:
João Barbosa 2019-01-21 16:57:22 +00:00
parent 6c49a55b47
commit be82dea23c
2 changed files with 9 additions and 1 deletions

View file

@ -26,11 +26,17 @@ WalletController::WalletController(interfaces::Node& node, const PlatformStyle*
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.getWallets()) { for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.getWallets()) {
getOrCreateWallet(std::move(wallet)); getOrCreateWallet(std::move(wallet));
} }
m_activity_thread.start();
} }
// Not using the default destructor because not all member types definitions are // Not using the default destructor because not all member types definitions are
// available in the header, just forward declared. // 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 std::vector<WalletModel*> WalletController::getWallets() const
{ {

View file

@ -13,6 +13,7 @@
#include <vector> #include <vector>
#include <QMutex> #include <QMutex>
#include <QThread>
class OptionsModel; class OptionsModel;
class PlatformStyle; class PlatformStyle;
@ -51,6 +52,7 @@ Q_SIGNALS:
void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction); void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction);
private: private:
QThread m_activity_thread;
interfaces::Node& m_node; interfaces::Node& m_node;
const PlatformStyle* const m_platform_style; const PlatformStyle* const m_platform_style;
OptionsModel* const m_options_model; OptionsModel* const m_options_model;