5
5
#include < qt/initexecutor.h>
6
6
7
7
#include < interfaces/node.h>
8
+ #include < qt/guiutil.h>
8
9
#include < util/system.h>
9
10
#include < util/threadnames.h>
10
11
18
19
InitExecutor::InitExecutor (interfaces::Node& node)
19
20
: QObject(), m_node(node)
20
21
{
21
- this -> moveToThread (&m_thread);
22
+ m_context. moveToThread (&m_thread);
22
23
m_thread.start ();
23
24
}
24
25
@@ -38,29 +39,33 @@ void InitExecutor::handleRunawayException(const std::exception* e)
38
39
39
40
void InitExecutor::initialize ()
40
41
{
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
+ });
52
55
}
53
56
54
57
void InitExecutor::shutdown ()
55
58
{
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
+ });
66
71
}
0 commit comments