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,30 @@ 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
+ interfaces::BlockAndHeaderTipInfo tip_info;
46
+ bool rv = m_node.appInitMain (&tip_info);
47
+ Q_EMIT initializeResult (rv, tip_info);
48
+ } catch (const std::exception& e) {
49
+ handleRunawayException (&e);
50
+ } catch (...) {
51
+ handleRunawayException (nullptr );
52
+ }
53
+ });
52
54
}
53
55
54
56
void InitExecutor::shutdown ()
55
57
{
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
- }
58
+ GUIUtil::ObjectInvoke (&m_context, [ this ] {
59
+ try {
60
+ m_node.appShutdown ();
61
+ Q_EMIT shutdownResult () ;
62
+ } catch ( const std::exception& e) {
63
+ handleRunawayException (&e);
64
+ } catch (...) {
65
+ handleRunawayException ( nullptr );
66
+ }
67
+ });
66
68
}
0 commit comments