mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 08:13:52 +02:00
qt, refactor: Move InitExecutor class into its own module
This change makes InitExecutor class re-usable by an alternative GUI, e.g., QML-based one.
This commit is contained in:
@@ -7,12 +7,19 @@
|
||||
#endif
|
||||
|
||||
#include <qt/bitcoin.h>
|
||||
#include <qt/bitcoingui.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <init.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <node/context.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <noui.h>
|
||||
#include <qt/bitcoingui.h>
|
||||
#include <qt/clientmodel.h>
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/initexecutor.h>
|
||||
#include <qt/intro.h>
|
||||
#include <qt/networkstyle.h>
|
||||
#include <qt/optionsmodel.h>
|
||||
@@ -20,6 +27,11 @@
|
||||
#include <qt/splashscreen.h>
|
||||
#include <qt/utilitydialog.h>
|
||||
#include <qt/winshutdownmonitor.h>
|
||||
#include <uint256.h>
|
||||
#include <util/system.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
#include <qt/paymentserver.h>
|
||||
@@ -27,18 +39,6 @@
|
||||
#include <qt/walletmodel.h>
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
#include <init.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <node/context.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <noui.h>
|
||||
#include <uint256.h>
|
||||
#include <util/system.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -155,58 +155,6 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
|
||||
}
|
||||
}
|
||||
|
||||
InitExecutor::InitExecutor(interfaces::Node& node) :
|
||||
QObject(), m_node(node)
|
||||
{
|
||||
this->moveToThread(&m_thread);
|
||||
m_thread.start();
|
||||
}
|
||||
|
||||
InitExecutor::~InitExecutor()
|
||||
{
|
||||
qDebug() << __func__ << ": Stopping thread";
|
||||
m_thread.quit();
|
||||
m_thread.wait();
|
||||
qDebug() << __func__ << ": Stopped thread";
|
||||
}
|
||||
|
||||
void InitExecutor::handleRunawayException(const std::exception *e)
|
||||
{
|
||||
PrintExceptionContinue(e, "Runaway exception");
|
||||
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));
|
||||
}
|
||||
|
||||
void InitExecutor::initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
util::ThreadRename("qt-init");
|
||||
qDebug() << __func__ << ": Running initialization in thread";
|
||||
interfaces::BlockAndHeaderTipInfo tip_info;
|
||||
bool rv = m_node.appInitMain(&tip_info);
|
||||
Q_EMIT initializeResult(rv, tip_info);
|
||||
} catch (const std::exception& e) {
|
||||
handleRunawayException(&e);
|
||||
} catch (...) {
|
||||
handleRunawayException(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void InitExecutor::shutdown()
|
||||
{
|
||||
try
|
||||
{
|
||||
qDebug() << __func__ << ": Running Shutdown in thread";
|
||||
m_node.appShutdown();
|
||||
qDebug() << __func__ << ": Shutdown finished";
|
||||
Q_EMIT shutdownResult();
|
||||
} catch (const std::exception& e) {
|
||||
handleRunawayException(&e);
|
||||
} catch (...) {
|
||||
handleRunawayException(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static int qt_argc = 1;
|
||||
static const char* qt_argv = "bitcoin-qt";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user