diff options
-rw-r--r-- | fxjs/JS_Define.h | 3 | ||||
-rw-r--r-- | fxjs/cjs_object.h | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/fxjs/JS_Define.h b/fxjs/JS_Define.h index 6de56f40e0..08654b96e1 100644 --- a/fxjs/JS_Define.h +++ b/fxjs/JS_Define.h @@ -13,6 +13,7 @@ #include "fxjs/cjs_return.h" #include "fxjs/fxjs_v8.h" #include "fxjs/js_resources.h" +#include "third_party/base/ptr_util.h" double JS_GetDateTime(); int JS_GetYearFromTime(double dt); @@ -49,7 +50,7 @@ std::vector<v8::Local<v8::Value>> ExpandKeywordParams( template <class T, class A> static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new T(obj); - pObj->SetEmbedObject(new A(pObj)); + pObj->SetEmbedObject(pdfium::MakeUnique<A>(pObj)); pEngine->SetObjectPrivate(obj, pObj); pObj->InitInstance(static_cast<CJS_Runtime*>(pEngine)); } diff --git a/fxjs/cjs_object.h b/fxjs/cjs_object.h index d929a01496..f4b0d297f4 100644 --- a/fxjs/cjs_object.h +++ b/fxjs/cjs_object.h @@ -8,6 +8,7 @@ #define FXJS_CJS_OBJECT_H_ #include <memory> +#include <utility> #include "fpdfsdk/fsdk_define.h" #include "fxjs/cjs_embedobj.h" @@ -57,7 +58,9 @@ class CJS_Object { v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); } // Takes ownership of |pObj|. - void SetEmbedObject(CJS_EmbedObj* pObj) { m_pEmbedObj.reset(pObj); } + void SetEmbedObject(std::unique_ptr<CJS_EmbedObj> pObj) { + m_pEmbedObj = std::move(pObj); + } CJS_EmbedObj* GetEmbedObject() const { return m_pEmbedObj.get(); } v8::Isolate* GetIsolate() const { return m_pIsolate; } |