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

Method runSetup

app/src/DataModel/Scripting/ControlScriptWorker.cpp:445–466  ·  view source on GitHub ↗

* @brief Runs the one-shot setup() function if the script defines it. */

Source from the content-addressed store, hash-verified

443 * @brief Runs the one-shot setup() function if the script defines it.
444 */
445void DataModel::ControlScriptWorker::runSetup()
446{
447 if (!m_loaded || !m_setupFn.isCallable() || !m_watchdog)
448 return;
449
450 QJSValueList args;
451 const QJSValue result = m_watchdog->call(m_setupFn, args);
452
453 if (m_watchdog->lastCallTimedOut()) {
454 Q_EMIT scriptError(
455 QStringLiteral("Control script setup() exceeded %1 ms budget.").arg(kRuntimeWatchdogMs));
456 stop();
457 return;
458 }
459
460 if (result.isError()) {
461 Q_EMIT scriptError(QStringLiteral("setup() line %1: %2")
462 .arg(result.property(QStringLiteral("lineNumber")).toInt())
463 .arg(result.toString()));
464 stop();
465 }
466}
467
468//--------------------------------------------------------------------------------------------------
469// Compilation

Callers

nothing calls this directly

Calls 4

stopFunction · 0.85
lastCallTimedOutMethod · 0.80
isErrorMethod · 0.80
callMethod · 0.45

Tested by

no test coverage detected