Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 3 files). Show all
Unified · Split
| @@ -462,6 +462,8 @@ void ScriptObjectV8Proxy::v8Get(v8::Local<v8::Name> name, const v8::PropertyCall · 461 unmodified lines | ||
| 462 | 462 | } |
| 463 | 463 | v8::Local<v8::String> v8NameString; |
| 464 | 464 | |
| 465 | + ContextScopeV8 contextScopeV8(proxy->_engine); | |
| 466 | + | |
| 465 | 467 | if (name->IsString()) { |
| 466 | 468 | V8ScriptString nameString(proxy->_engine, v8::Local<v8::String>::Cast(name)); |
| 467 | 469 | uint id; |
| @@ -497,6 +499,8 @@ void ScriptObjectV8Proxy::v8Set(v8::Local<v8::Name> name, v8::Local<v8::Value> v · 29 unmodified lines | ||
| 497 | 499 | Q_ASSERT(false); |
| 498 | 500 | } |
| 499 | 501 | |
| 502 | + ContextScopeV8 contextScopeV8(proxy->_engine); | |
| 503 | + | |
| 500 | 504 | if (name->IsString()) { |
| 501 | 505 | V8ScriptString nameString(proxy->_engine, v8::Local<v8::String>::Cast(name)); |
| 502 | 506 | uint id; |
| @@ -800,6 +804,8 @@ void ScriptVariantV8Proxy::v8Get(v8::Local<v8::Name> name, const v8::PropertyCal · 297 unmodified lines | ||
| 800 | 804 | } |
| 801 | 805 | V8ScriptValue object(proxy->_engine, proxy->_v8Object.Get(info.GetIsolate())); |
| 802 | 806 | |
| 807 | + ContextScopeV8 contextScopeV8(proxy->_engine); | |
| 808 | + | |
| 803 | 809 | if (name->IsString()) { |
| 804 | 810 | V8ScriptString nameString(proxy->_engine, v8::Local<v8::String>::Cast(name)); |
| 805 | 811 | uint id; |
| @@ -831,6 +837,7 @@ void ScriptVariantV8Proxy::v8Set(v8::Local<v8::Name> name, v8::Local<v8::Value> · 25 unmodified lines | ||
| 831 | 837 | Q_ASSERT(false); |
| 832 | 838 | } |
| 833 | 839 | |
| 840 | + ContextScopeV8 contextScopeV8(proxy->_engine); | |
| 834 | 841 | if (name->IsString()) { |
| 835 | 842 | V8ScriptString nameString(proxy->_engine, v8::Local<v8::String>::Cast(name)); |
| 836 | 843 | uint id; |
| @@ -940,16 +947,8 @@ void ScriptMethodV8Proxy::callback(const v8::FunctionCallbackInfo<v8::Value>& ar · 103 unmodified lines | ||
| 940 | 947 | } |
| 941 | 948 | ScriptMethodV8Proxy *proxy = reinterpret_cast<ScriptMethodV8Proxy*>(data->GetAlignedPointerFromInternalField(1)); |
| 942 | 949 | |
| 943 | − // V8TODO: all other V8 callbacks need this too | |
| 944 | − bool isContextChangeNeeded = (proxy->_engine->getContext() != arguments.GetIsolate()->GetCurrentContext()); | |
| 945 | − if (isContextChangeNeeded) { | |
| 946 | − qDebug() << "ScriptMethodV8Proxy::callback : changing context"; | |
| 947 | − proxy->_engine->pushContext(arguments.GetIsolate()->GetCurrentContext()); | |
| 948 | − } | |
| 950 | + ContextScopeV8 contextScopeV8(proxy->_engine); | |
| 949 | 951 | proxy->call(arguments); |
| 950 | − if (isContextChangeNeeded) { | |
| 951 | − proxy->_engine->popContext(); | |
| 952 | − } | |
| 953 | 952 | } |
| 954 | 953 | |
| 955 | 954 | void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo<v8::Value>& arguments) { |
| @@ -958,6 +957,7 @@ void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo<v8::Value>& argume · 2 unmodified lines | ||
| 958 | 957 | v8::Locker locker(isolate); |
| 959 | 958 | v8::Isolate::Scope isolateScope(isolate); |
| 960 | 959 | v8::HandleScope handleScope(isolate); |
| 960 | + ContextScopeV8 contextScopeV8(_engine); | |
| 961 | 961 | v8::Context::Scope contextScope(_engine->getContext()); |
| 962 | 962 | QObject* qobject = _object; |
| 963 | 963 | if (!qobject) { |