Showing the changes to libraries/script-engine/src/BaseScriptEngine.cpp (1 of 3 files). Show all
Unified · Split
| @@ -210,10 +210,9 @@ QScriptValue BaseScriptEngine::evaluateInClosure(const QScriptValue& closure, co · 209 unmodified lines | |||
| 210 | qCDebug(scriptengine) << QString("[%1] evaluateInClosure %2").arg(isEvaluating()).arg(shortName); | 210 | qCDebug(scriptengine) << QString("[%1] evaluateInClosure %2").arg(isEvaluating()).arg(shortName); |
| 211 | #endif | 211 | #endif |
| 212 | { | 212 | { |
| 213 | ExceptionEmitter tryCatch(this, __FUNCTION__); | ||
| 214 | result = BaseScriptEngine::evaluate(program); | 213 | result = BaseScriptEngine::evaluate(program); |
| 215 | if (tryCatch.hasPending()) { | 214 | if (hasUncaughtException()) { |
| 216 | auto err = tryCatch.pending(); | 215 | auto err = cloneUncaughtException(__FUNCTION__); |
| 217 | #ifdef DEBUG_JS_EXCEPTIONS | 216 | #ifdef DEBUG_JS_EXCEPTIONS |
| 218 | qCWarning(scriptengine) << __FUNCTION__ << "---------- hasCaught:" << err.toString() << result.toString(); | 217 | qCWarning(scriptengine) << __FUNCTION__ << "---------- hasCaught:" << err.toString() << result.toString(); |
| 219 | err.setProperty("_result", result); | 218 | err.setProperty("_result", result); |
| @@ -266,37 +265,6 @@ QScriptValue Lambda::call() { · 46 unmodified lines | |||
| 266 | return operation(engine->currentContext(), engine); | 265 | return operation(engine->currentContext(), engine); |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | // BaseScriptEngine::ExceptionEmitter | ||
| 270 | |||
| 271 | void BaseScriptEngine::_emitUnhandledException(const QScriptValue& exception) { | ||
| 272 | emit unhandledException(exception); | ||
| 273 | } | ||
| 274 | BaseScriptEngine::ExceptionEmitter::ExceptionEmitter(BaseScriptEngine* engine, const QString& debugName) | ||
| 275 | : _engine(engine), _debugName(debugName) { | ||
| 276 | } | ||
| 277 | bool BaseScriptEngine::ExceptionEmitter::hasPending() { | ||
| 278 | return _engine->hasUncaughtException(); | ||
| 279 | } | ||
| 280 | QScriptValue BaseScriptEngine::ExceptionEmitter::pending() { | ||
| 281 | return _engine->cloneUncaughtException(_debugName); | ||
| 282 | } | ||
| 283 | QScriptValue BaseScriptEngine::ExceptionEmitter::consume() { | ||
| 284 | if (hasPending()) { | ||
| 285 | _consumedException = pending(); | ||
| 286 | _engine->clearExceptions(); | ||
| 287 | } | ||
| 288 | return _consumedException; | ||
| 289 | } | ||
| 290 | bool BaseScriptEngine::ExceptionEmitter::wouldEmit() { | ||
| 291 | return !_engine->isEvaluating() && _engine->hasUncaughtException(); | ||
| 292 | } | ||
| 293 | BaseScriptEngine::ExceptionEmitter::~ExceptionEmitter() { | ||
| 294 | if (wouldEmit()) { | ||
| 295 | _engine->_emitUnhandledException(consume()); | ||
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 | |||
| 300 | #ifdef DEBUG_JS | 268 | #ifdef DEBUG_JS |
| 301 | void BaseScriptEngine::_debugDump(const QString& header, const QScriptValue& object, const QString& footer) { | 269 | void BaseScriptEngine::_debugDump(const QString& header, const QScriptValue& object, const QString& footer) { |
| 302 | if (!header.isEmpty()) { | 270 | if (!header.isEmpty()) { |