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