From 20fc82efdc9c9e4caa6e72d05a83b9206e8c8f72 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 1 Oct 2015 17:40:14 -0700 Subject: Fix static initializer in fxjs_v8.cpp R=thestig@chromium.org Review URL: https://codereview.chromium.org/1372103004 . --- fpdfsdk/src/jsapi/fxjs_v8.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index a626bce345..667132fde4 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -24,7 +24,7 @@ static unsigned int g_embedderDataSlot = 1u; // kPerContextDataStartIndex + kEmbedderPDFium, which is 3. static const unsigned int kPerContextDataIndex = 3u; -static v8::Global g_DefaultGlobalObjectTemplate; +static v8::Global* g_DefaultGlobalObjectTemplate = nullptr; class CFXJS_PrivateData { public: @@ -111,11 +111,12 @@ static v8::Local GetGlobalObjectTemplate( return pObjDef->GetInstanceTemplate(); } - if (g_DefaultGlobalObjectTemplate.IsEmpty()) - g_DefaultGlobalObjectTemplate.Reset(pIsolate, - v8::ObjectTemplate::New(pIsolate)); - - return g_DefaultGlobalObjectTemplate.Get(pIsolate); + if (!g_DefaultGlobalObjectTemplate) { + g_DefaultGlobalObjectTemplate = new v8::Global; + g_DefaultGlobalObjectTemplate->Reset(pIsolate, + v8::ObjectTemplate::New(pIsolate)); + } + return g_DefaultGlobalObjectTemplate->Get(pIsolate); } void* FXJS_ArrayBufferAllocator::Allocate(size_t length) { -- cgit v1.2.3