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 | 210 | qCDebug(scriptengine) << QString("[%1] evaluateInClosure %2").arg(isEvaluating()).arg(shortName); |
| 211 | 211 | #endif |
| 212 | 212 | { |
| 213 | − ExceptionEmitter tryCatch(this, __FUNCTION__); | |
| 214 | 213 | result = BaseScriptEngine::evaluate(program); |
| 215 | − if (tryCatch.hasPending()) { | |
| 216 | − auto err = tryCatch.pending(); | |
| 214 | + if (hasUncaughtException()) { | |
| 215 | + auto err = cloneUncaughtException(__FUNCTION__); | |
| 217 | 216 | #ifdef DEBUG_JS_EXCEPTIONS |
| 218 | 217 | qCWarning(scriptengine) << __FUNCTION__ << "---------- hasCaught:" << err.toString() << result.toString(); |
| 219 | 218 | err.setProperty("_result", result); |
| @@ -266,37 +265,6 @@ QScriptValue Lambda::call() { · 46 unmodified lines | ||
| 266 | 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 | 268 | #ifdef DEBUG_JS |
| 301 | 269 | void BaseScriptEngine::_debugDump(const QString& header, const QScriptValue& object, const QString& footer) { |
| 302 | 270 | if (!header.isEmpty()) { |