55#include < qt/initexecutor.h>
66
77#include < interfaces/node.h>
8+ #include < qt/guiutil.h>
89#include < util/system.h>
910#include < util/threadnames.h>
1011
1819InitExecutor::InitExecutor (interfaces::Node& node)
1920 : QObject(), m_node(node)
2021{
21- this -> moveToThread (&m_thread);
22+ m_context. moveToThread (&m_thread);
2223 m_thread.start ();
2324}
2425
@@ -38,29 +39,33 @@ void InitExecutor::handleRunawayException(const std::exception* e)
3839
3940void InitExecutor::initialize ()
4041{
41- try {
42- util::ThreadRename (" qt-init" );
43- qDebug () << __func__ << " : Running initialization in thread" ;
44- interfaces::BlockAndHeaderTipInfo tip_info;
45- bool rv = m_node.appInitMain (&tip_info);
46- Q_EMIT initializeResult (rv, tip_info);
47- } catch (const std::exception& e) {
48- handleRunawayException (&e);
49- } catch (...) {
50- handleRunawayException (nullptr );
51- }
42+ GUIUtil::ObjectInvoke (&m_context, [this ] {
43+ try {
44+ util::ThreadRename (" qt-init" );
45+ qDebug () << " Running initialization in thread" ;
46+ interfaces::BlockAndHeaderTipInfo tip_info;
47+ bool rv = m_node.appInitMain (&tip_info);
48+ Q_EMIT initializeResult (rv, tip_info);
49+ } catch (const std::exception& e) {
50+ handleRunawayException (&e);
51+ } catch (...) {
52+ handleRunawayException (nullptr );
53+ }
54+ });
5255}
5356
5457void InitExecutor::shutdown ()
5558{
56- try {
57- qDebug () << __func__ << " : Running Shutdown in thread" ;
58- m_node.appShutdown ();
59- qDebug () << __func__ << " : Shutdown finished" ;
60- Q_EMIT shutdownResult ();
61- } catch (const std::exception& e) {
62- handleRunawayException (&e);
63- } catch (...) {
64- handleRunawayException (nullptr );
65- }
59+ GUIUtil::ObjectInvoke (&m_context, [this ] {
60+ try {
61+ qDebug () << " Running Shutdown in thread" ;
62+ m_node.appShutdown ();
63+ qDebug () << " Shutdown finished" ;
64+ Q_EMIT shutdownResult ();
65+ } catch (const std::exception& e) {
66+ handleRunawayException (&e);
67+ } catch (...) {
68+ handleRunawayException (nullptr );
69+ }
70+ });
6671}
0 commit comments