summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/jsapi/fxjs_v8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/jsapi/fxjs_v8.cpp')
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp13
1 files 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<v8::ObjectTemplate> g_DefaultGlobalObjectTemplate;
+static v8::Global<v8::ObjectTemplate>* g_DefaultGlobalObjectTemplate = nullptr;
class CFXJS_PrivateData {
public:
@@ -111,11 +111,12 @@ static v8::Local<v8::ObjectTemplate> 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<v8::ObjectTemplate>;
+ g_DefaultGlobalObjectTemplate->Reset(pIsolate,
+ v8::ObjectTemplate::New(pIsolate));
+ }
+ return g_DefaultGlobalObjectTemplate->Get(pIsolate);
}
void* FXJS_ArrayBufferAllocator::Allocate(size_t length) {