Showing the changes to libraries/script-engine/src/v8/ScriptEngineV8.cpp (1 of 3 files). Show all
Unified · Split
| @@ -1164,6 +1164,7 @@ ScriptValue ScriptEngineV8::newFunction(ScriptEngine::FunctionSignature fun, int · 1163 unmodified lines | |||
| 1164 | (object->GetAlignedPointerFromInternalField(0)); | 1164 | (object->GetAlignedPointerFromInternalField(0)); |
| 1165 | ScriptEngineV8 *scriptEngine = reinterpret_cast<ScriptEngineV8*> | 1165 | ScriptEngineV8 *scriptEngine = reinterpret_cast<ScriptEngineV8*> |
| 1166 | (object->GetAlignedPointerFromInternalField(1)); | 1166 | (object->GetAlignedPointerFromInternalField(1)); |
| 1167 | ContextScopeV8 contextScopeV8(scriptEngine); | ||
| 1167 | ScriptContextV8Wrapper scriptContext(scriptEngine, &info, scriptEngine->getContext(), scriptEngine->currentContext()->parentContext()); | 1168 | ScriptContextV8Wrapper scriptContext(scriptEngine, &info, scriptEngine->getContext(), scriptEngine->currentContext()->parentContext()); |
| 1168 | ScriptContextGuard scriptContextGuard(&scriptContext); | 1169 | ScriptContextGuard scriptContextGuard(&scriptContext); |
| 1169 | ScriptValue result = function(&scriptContext, scriptEngine); | 1170 | ScriptValue result = function(&scriptContext, scriptEngine); |
| @@ -1433,3 +1434,18 @@ void ScriptEngineV8::dumpHeapObjectStatistics() { · 263 unmodified lines | |||
| 1433 | } | 1434 | } |
| 1434 | } | 1435 | } |
| 1435 | } | 1436 | } |
| 1437 | |||
| 1438 | ContextScopeV8::ContextScopeV8(ScriptEngineV8 *engine) : | ||
| 1439 | _engine(engine) { | ||
| 1440 | Q_ASSERT(engine); | ||
| 1441 | _isContextChangeNeeded = engine->getContext() != engine->getIsolate()->GetCurrentContext(); | ||
| 1442 | if (_isContextChangeNeeded) { | ||
| 1443 | engine->pushContext(engine->getIsolate()->GetCurrentContext()); | ||
| 1444 | } | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | ContextScopeV8::~ContextScopeV8() { | ||
| 1448 | if (_isContextChangeNeeded) { | ||
| 1449 | _engine->popContext(); | ||
| 1450 | } | ||
| 1451 | } | ||