| Index: src/JsEngine.cpp | 
| =================================================================== | 
| --- a/src/JsEngine.cpp | 
| +++ b/src/JsEngine.cpp | 
| @@ -91,13 +91,16 @@ | 
| result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(), | 
| v8::Context::New(result->GetIsolate()))); | 
| - v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( | 
| - result->GetIsolate(), *result->context)->Global(); | 
| - result->globalJsObject = JsValuePtr(new JsValue(result, globalContext)); | 
| - AdblockPlus::GlobalJsObject::Setup(result, appInfo, result->globalJsObject); | 
| + AdblockPlus::GlobalJsObject::Setup(result, appInfo, result->GetGlobalObject()); | 
| return result; | 
| } | 
| +AdblockPlus::JsValuePtr AdblockPlus::JsEngine::GetGlobalObject() | 
| +{ | 
| + JsContext context(shared_from_this()); | 
| + return JsValuePtr(new JsValue(shared_from_this(), context.GetV8Context()->Global())); | 
| 
 
Eric
2016/11/28 17:51:27
`JsContext` creates a scope that's entered upon co
 
sergei
2016/11/29 09:47:12
I would merely like to clarify here that not "the
 
Eric
2016/11/30 17:59:46
Right. I had a problem on an earlier iteration of
 
 | 
| +}; | 
| 
 
sergei
2016/11/29 09:47:12
Nit: no semicolon.
 
Eric
2016/11/30 17:59:46
Done.
 
 | 
| + | 
| AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& source, | 
| const std::string& filename) | 
| { | 
| @@ -244,8 +247,8 @@ | 
| void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, | 
| AdblockPlus::JsValuePtr value) | 
| { | 
| - if (!globalJsObject) | 
| + auto global = GetGlobalObject(); | 
| + if (!global) | 
| throw std::runtime_error("Global object cannot be null"); | 
| - | 
| - globalJsObject->SetProperty(name, value); | 
| + global->SetProperty(name, value); | 
| } |