diff options
Diffstat (limited to 'fxjs')
-rw-r--r-- | fxjs/fxjs_v8.cpp | 11 | ||||
-rw-r--r-- | fxjs/fxjs_v8.h | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp index 7869bab038..773f9025b1 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/fxjs_v8.cpp @@ -417,9 +417,7 @@ void CFXJS_Engine::InitializeEngine() { v8::Local<v8::Object> obj = NewFxDynamicObj(i, true); if (!obj.IsEmpty()) { v8Context->Global()->Set(v8Context, pObjName, obj).FromJust(); - m_StaticObjects[i] = new v8::Global<v8::Object>(GetIsolate(), obj); - } else { - m_StaticObjects[i] = nullptr; + m_StaticObjects[i] = v8::Global<v8::Object>(GetIsolate(), obj); } } } @@ -444,10 +442,9 @@ void CFXJS_Engine::ReleaseEngine() { if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) { pObj = context->Global()->GetPrototype()->ToObject(context).ToLocalChecked(); - } else if (m_StaticObjects[i] && !m_StaticObjects[i]->IsEmpty()) { - pObj = v8::Local<v8::Object>::New(GetIsolate(), *m_StaticObjects[i]); - delete m_StaticObjects[i]; - m_StaticObjects[i] = nullptr; + } else if (!m_StaticObjects[i].IsEmpty()) { + pObj = v8::Local<v8::Object>::New(GetIsolate(), m_StaticObjects[i]); + m_StaticObjects[i].Reset(); } if (!pObj.IsEmpty()) { diff --git a/fxjs/fxjs_v8.h b/fxjs/fxjs_v8.h index 9dcaeb84c1..3e8e861403 100644 --- a/fxjs/fxjs_v8.h +++ b/fxjs/fxjs_v8.h @@ -198,7 +198,7 @@ class CFXJS_Engine : public CJS_V8 { private: v8::Global<v8::Context> m_V8Context; - std::vector<v8::Global<v8::Object>*> m_StaticObjects; + std::vector<v8::Global<v8::Object>> m_StaticObjects; std::map<WideString, v8::Global<v8::Array>> m_ConstArrays; }; |