MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / ensureStarted

Method ensureStarted

app/src/DataModel/Scripting/JsWatchdogThread.cpp:179–197  ·  view source on GitHub ↗

* @brief Spins up the worker thread once and arranges an orderly stop at app exit. */

Source from the content-addressed store, hash-verified

177 * @brief Spins up the worker thread once and arranges an orderly stop at app exit.
178 */
179void DataModel::JsWatchdogThread::ensureStarted()
180{
181 if (m_started)
182 return;
183
184 m_thread = new QThread();
185 m_thread->setObjectName(QStringLiteral("JsWatchdog"));
186
187 m_worker = new JsWatchdogWorker();
188 m_worker->moveToThread(m_thread);
189
190 QObject::connect(m_thread, &QThread::started, m_worker, &JsWatchdogWorker::begin);
191 m_thread->start();
192
193 if (auto* app = QCoreApplication::instance())
194 QObject::connect(app, &QCoreApplication::aboutToQuit, app, [this]() { shutdown(); });
195
196 m_started = true;
197}
198
199/**
200 * @brief Stops the worker thread and releases it; idempotent and main-thread safe. finish()

Callers

nothing calls this directly

Calls 1

startMethod · 0.45

Tested by

no test coverage detected