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

Method runLoadedChunk

app/src/DataModel/Scripting/LuaScriptEngine.cpp:359–378  ·  view source on GitHub ↗

* @brief Runs the just-loaded chunk under the watchdog and reports any runtime error. */

Source from the content-addressed store, hash-verified

357 * @brief Runs the just-loaded chunk under the watchdog and reports any runtime error.
358 */
359bool DataModel::LuaScriptEngine::runLoadedChunk(int sourceId, bool showMessageBoxes)
360{
361 m_deadline.setRemainingTime(kRuntimeWatchdogMs);
362 const int status = guardedPcall(m_state, 0, 0, 0);
363 m_deadline = QDeadlineTimer(QDeadlineTimer::Forever);
364 if (status == LUA_OK)
365 return true;
366
367 const QString errorMsg = QString::fromUtf8(lua_tostring(m_state, -1));
368 lua_pop(m_state, 1);
369 if (showMessageBoxes) {
370 Misc::Utilities::showMessageBox(
371 QObject::tr("Lua Runtime Error"),
372 QObject::tr("The parser code triggered an error:\n\n%1").arg(errorMsg),
373 QMessageBox::Critical);
374 } else {
375 qWarning() << "[LuaScriptEngine] Source" << sourceId << "runtime error:" << errorMsg;
376 }
377 return false;
378}
379
380/**
381 * @brief Confirms that a global 'parse' function was declared by the chunk.

Callers

nothing calls this directly

Calls 1

guardedPcallFunction · 0.85

Tested by

no test coverage detected