* @brief Runs the just-loaded chunk under the watchdog and reports any runtime error. */
| 357 | * @brief Runs the just-loaded chunk under the watchdog and reports any runtime error. |
| 358 | */ |
| 359 | bool 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. |
nothing calls this directly
no test coverage detected