aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletcontroller.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-10-12 22:26:47 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-10-26 13:02:55 +0200
commite39c9cff1a626ee038a541258d6e271ce63969a9 (patch)
tree86d0bbc3ef8c4aafb6ab2ea68295d9af5ed894d3 /src/qt/walletcontroller.cpp
parent8082b3847ad24f54ee690651313a511829545246 (diff)
gui: Fix start timer from non QThread
Github-Pull: #17120 Rebased-From: a8f5026d6d992fd8d72908c848c5028f0f9a8cd1 Tree-SHA512: 5f8cbfd5044d2c0df7dbfc54e7d94f93da96d0adecd23007e82acc38bc3c7984a685c9596cbd449f559cf42db9e1b99612765328004c5a45655a8e375482a8a8
Diffstat (limited to 'src/qt/walletcontroller.cpp')
-rw-r--r--src/qt/walletcontroller.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index fa6f9f3f16..a8de5392b4 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -108,6 +108,12 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
wallet_model->setParent(this);
m_wallets.push_back(wallet_model);
+ // WalletModel::startPollBalance needs to be called in a thread managed by
+ // Qt because of startTimer. Considering the current thread can be a RPC
+ // thread, better delegate the calling to Qt with Qt::AutoConnection.
+ const bool called = QMetaObject::invokeMethod(wallet_model, "startPollBalance");
+ assert(called);
+
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
// Defer removeAndDeleteWallet when no modal widget is active.
// TODO: remove this workaround by removing usage of QDiallog::exec.