Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletcontroller.cpp
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | WalletModel *WalletController::getOrCreateWallet( | ||||
WalletModel *wallet_model = new WalletModel( | WalletModel *wallet_model = new WalletModel( | ||||
std::move(wallet), m_node, m_platform_style, m_options_model, nullptr); | std::move(wallet), m_node, m_platform_style, m_options_model, nullptr); | ||||
// Handler callback runs in a different thread so fix wallet model thread | // Handler callback runs in a different thread so fix wallet model thread | ||||
// affinity. | // affinity. | ||||
wallet_model->moveToThread(thread()); | wallet_model->moveToThread(thread()); | ||||
wallet_model->setParent(this); | wallet_model->setParent(this); | ||||
m_wallets.push_back(wallet_model); | 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( | connect( | ||||
wallet_model, &WalletModel::unload, this, | wallet_model, &WalletModel::unload, this, | ||||
[this, wallet_model] { | [this, wallet_model] { | ||||
// Defer removeAndDeleteWallet when no modal widget is active. | // Defer removeAndDeleteWallet when no modal widget is active. | ||||
// TODO: remove this workaround by removing usage of QDiallog::exec. | // TODO: remove this workaround by removing usage of QDiallog::exec. | ||||
if (QApplication::activeModalWidget()) { | if (QApplication::activeModalWidget()) { | ||||
connect( | connect( | ||||
qApp, &QApplication::focusWindowChanged, wallet_model, | qApp, &QApplication::focusWindowChanged, wallet_model, | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |