Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions src/qt/initexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <qt/initexecutor.h>

#include <interfaces/node.h>
#include <qt/guiutil.h>
#include <util/system.h>
#include <util/threadnames.h>

Expand All @@ -18,7 +19,7 @@
InitExecutor::InitExecutor(interfaces::Node& node)
: QObject(), m_node(node)
{
this->moveToThread(&m_thread);
m_context.moveToThread(&m_thread);
m_thread.start();
}

Expand All @@ -38,29 +39,33 @@ void InitExecutor::handleRunawayException(const std::exception* e)

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);
}
GUIUtil::ObjectInvoke(&m_context, [this] {
try {
util::ThreadRename("qt-init");
qDebug() << "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);
}
GUIUtil::ObjectInvoke(&m_context, [this] {
try {
qDebug() << "Running Shutdown in thread";
m_node.appShutdown();
qDebug() << "Shutdown finished";
Q_EMIT shutdownResult();
} catch (const std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(nullptr);
}
});
}
1 change: 1 addition & 0 deletions src/qt/initexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public Q_SLOTS:
void handleRunawayException(const std::exception* e);

interfaces::Node& m_node;
QObject m_context;
QThread m_thread;
};

Expand Down
1 change: 0 additions & 1 deletion src/qt/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <interfaces/init.h>
#include <interfaces/node.h>
#include <qt/bitcoin.h>
#include <qt/initexecutor.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I cannot imagine the reason how it slipped in #381 🤷‍♂️

#include <qt/test/apptests.h>
#include <qt/test/rpcnestedtests.h>
#include <qt/test/uritests.h>
Expand Down