307 | @@ -308,7 +308,7 @@ void BitcoinApplication::startThread()
308 |
309 | /* communication to and from thread */
310 | connect(&m_executor.value(), &InitExecutor::initializeResult, this, &BitcoinApplication::initializeResult);
311 | - connect(&m_executor.value(), &InitExecutor::shutdownResult, this, &QCoreApplication::quit);
312 | + connect(&m_executor.value(), &InitExecutor::shutdownResult, [] { QCoreApplication::exit(0); });
The signal shutdownResult is emitted from executor's thread and this results in calling exit() in that thread because the connection lacks a context. But exit() must be called in the main thread: https://doc-snapshots.qt.io/qt6-dev/qcoreapplication.html#exit. Maybe:
connect(&m_executor.value(), &InitExecutor::shutdownResult, this, [] {
QCoreApplication::exit(0);
});
~Why? QCoreApplication::exit() is a static member function.~
You are right.
Yes, but according to the doc
Note also that this function is not thread-safe. It should be called only from the main thread
and by using https://doc.qt.io/qt-5/qobject.html#connect-5 we ensure that lambda is called on the right thread.