Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void initializeResult(bool success); | void initializeResult(bool success); | ||||
void shutdownResult(); | void shutdownResult(); | ||||
/// Handle runaway exceptions. Shows a message box with the problem and | /// Handle runaway exceptions. Shows a message box with the problem and | ||||
/// quits the program. | /// quits the program. | ||||
void handleRunawayException(const QString &message); | void handleRunawayException(const QString &message); | ||||
void addWallet(WalletModel *walletModel); | void addWallet(WalletModel *walletModel); | ||||
void removeWallet(); | |||||
Q_SIGNALS: | Q_SIGNALS: | ||||
void requestedInitialize(Config *config, RPCServer *rpcServer, | void requestedInitialize(Config *config, RPCServer *rpcServer, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor); | HTTPRPCRequestProcessor *httpRPCRequestProcessor); | ||||
void requestedShutdown(); | void requestedShutdown(); | ||||
void stopThread(); | void stopThread(); | ||||
void splashFinished(QWidget *window); | void splashFinished(QWidget *window); | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | if (m_wallet_models.empty()) { | ||||
window->setCurrentWallet(walletModel->getWalletName()); | window->setCurrentWallet(walletModel->getWalletName()); | ||||
} | } | ||||
connect(walletModel, | connect(walletModel, | ||||
SIGNAL(coinsSent(WalletModel *, SendCoinsRecipient, QByteArray)), | SIGNAL(coinsSent(WalletModel *, SendCoinsRecipient, QByteArray)), | ||||
paymentServer, | paymentServer, | ||||
SLOT(fetchPaymentACK(WalletModel *, const SendCoinsRecipient &, | SLOT(fetchPaymentACK(WalletModel *, const SendCoinsRecipient &, | ||||
QByteArray))); | QByteArray))); | ||||
connect(walletModel, SIGNAL(unload()), this, SLOT(removeWallet())); | |||||
m_wallet_models.push_back(walletModel); | m_wallet_models.push_back(walletModel); | ||||
#endif | #endif | ||||
} | } | ||||
void BitcoinApplication::removeWallet() { | |||||
#ifdef ENABLE_WALLET | |||||
WalletModel *walletModel = static_cast<WalletModel *>(sender()); | |||||
m_wallet_models.erase( | |||||
std::find(m_wallet_models.begin(), m_wallet_models.end(), walletModel)); | |||||
window->removeWallet(walletModel); | |||||
walletModel->deleteLater(); | |||||
#endif | |||||
} | |||||
void BitcoinApplication::initializeResult(bool success) { | void BitcoinApplication::initializeResult(bool success) { | ||||
qDebug() << __func__ << ": Initialization result: " << success; | qDebug() << __func__ << ": Initialization result: " << success; | ||||
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; | returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; | ||||
if (!success) { | if (!success) { | ||||
// Make sure splash screen doesn't stick around during shutdown. | // Make sure splash screen doesn't stick around during shutdown. | ||||
Q_EMIT splashFinished(window); | Q_EMIT splashFinished(window); | ||||
// Exit first main loop invocation. | // Exit first main loop invocation. | ||||
quit(); | quit(); | ||||
return; | return; | ||||
} | } | ||||
// Log this only after AppInitMain finishes, as then logging setup is | // Log this only after AppInitMain finishes, as then logging setup is | ||||
// guaranteed complete. | // guaranteed complete. | ||||
qWarning() << "Platform customization:" << platformStyle->getName(); | qWarning() << "Platform customization:" << platformStyle->getName(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
PaymentServer::LoadRootCAs(); | PaymentServer::LoadRootCAs(); | ||||
paymentServer->setOptionsModel(optionsModel); | paymentServer->setOptionsModel(optionsModel); | ||||
#endif | #endif | ||||
clientModel = new ClientModel(m_node, optionsModel); | clientModel = new ClientModel(m_node, optionsModel); | ||||
window->setClientModel(clientModel); | window->setClientModel(clientModel); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
m_handler_load_wallet = m_node.handleLoadWallet( | m_handler_load_wallet = m_node.handleLoadWallet( | ||||
[this](std::unique_ptr<interfaces::Wallet> wallet) { | [this](std::unique_ptr<interfaces::Wallet> wallet) { | ||||
QMetaObject::invokeMethod( | WalletModel *wallet_model = | ||||
this, "addWallet", Qt::QueuedConnection, | |||||
Q_ARG(WalletModel *, | |||||
new WalletModel(std::move(wallet), m_node, platformStyle, | new WalletModel(std::move(wallet), m_node, platformStyle, | ||||
optionsModel))); | optionsModel, nullptr); | ||||
// Fix wallet model thread affinity. | |||||
wallet_model->moveToThread(thread()); | |||||
QMetaObject::invokeMethod(this, "addWallet", Qt::QueuedConnection, | |||||
Q_ARG(WalletModel *, wallet_model)); | |||||
}); | }); | ||||
for (auto &wallet : m_node.getWallets()) { | for (auto &wallet : m_node.getWallets()) { | ||||
addWallet(new WalletModel(std::move(wallet), m_node, platformStyle, | addWallet(new WalletModel(std::move(wallet), m_node, platformStyle, | ||||
optionsModel)); | optionsModel)); | ||||
} | } | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |