* @brief Builds the worker on its own thread and tracks the connection lifecycle. The worker * thread is joined at the start of ModuleManager::onQuit() while every module is still * alive (aboutToQuit stays connected as an idempotent fallback); the marshaller is * parented to this singleton so it outlives the worker thread. */
| 57 | * parented to this singleton so it outlives the worker thread. |
| 58 | */ |
| 59 | DataModel::ControlScript::ControlScript() |
| 60 | : m_ready(false) |
| 61 | , m_running(false) |
| 62 | , m_shouldRun(false) |
| 63 | , m_shutdown(false) |
| 64 | , m_worker(nullptr) |
| 65 | , m_marshaller(nullptr) |
| 66 | { |
| 67 | m_marshaller = new ControlApiMarshaller(this); |
| 68 | m_worker = new ControlScriptWorker(m_marshaller); |
| 69 | m_worker->moveToThread(&m_thread); |
| 70 | |
| 71 | connect(&m_thread, &QThread::finished, m_worker, &QObject::deleteLater); |
| 72 | connect(m_worker, &ControlScriptWorker::scriptError, this, &ControlScript::onWorkerError); |
| 73 | connect( |
| 74 | QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &ControlScript::shutdown); |
| 75 | |
| 76 | m_thread.start(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * @brief Wires the lifecycle signals after singletons exist, avoiding recursive static init. |