diff options
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_app.h | 3 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/jsapi/fxjs_v8.cpp | 5 | ||||
-rw-r--r-- | xfa/include/fxjse/fxjse.h | 2 | ||||
-rw-r--r-- | xfa/src/fxjse/src/runtime.cpp | 11 |
7 files changed, 22 insertions, 16 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h index dd65042189..5ec6de5644 100644 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h @@ -19,7 +19,7 @@ class CPDFXFA_App : public IXFA_AppProvider { CPDFXFA_App(); ~CPDFXFA_App() override; - FX_BOOL Initialize(); + FX_BOOL Initialize(FXJSE_HRUNTIME hRuntime); IXFA_App* GetXFAApp() { return m_pXFAApp; } FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv); @@ -92,6 +92,7 @@ class CPDFXFA_App : public IXFA_AppProvider { FXJSE_HRUNTIME m_hJSERuntime; IFXJS_Runtime* m_pJSRuntime; CFX_WideString m_csAppType; + bool m_bOwnedRuntime; }; #endif // FPDFXFA_APP_H_ diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index ba647093eb..418d35d720 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -241,7 +241,10 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( pModuleMgr->InitPageModule(); pModuleMgr->InitRenderModule(); #ifdef PDF_ENABLE_XFA - CPDFXFA_App::GetInstance()->Initialize(); + CPDFXFA_App::GetInstance()->Initialize( + (cfg && cfg->version >= 2) + ? reinterpret_cast<FXJSE_HRUNTIME>(cfg->m_pIsolate) + : nullptr); #else // PDF_ENABLE_XFA pModuleMgr->LoadEmbeddedGB1CMaps(); pModuleMgr->LoadEmbeddedJapan1CMaps(); diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp index 44e9c72ddc..1006bf9c44 100644 --- a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp +++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp @@ -31,7 +31,8 @@ CPDFXFA_App::CPDFXFA_App() m_pXFAApp(NULL), m_pFontMgr(NULL), m_hJSERuntime(NULL), - m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { + m_csAppType(JS_STR_VIEWERTYPE_STANDARD), + m_bOwnedRuntime(false) { m_pEnvList.RemoveAll(); } @@ -43,7 +44,7 @@ CPDFXFA_App::~CPDFXFA_App() { m_pXFAApp = NULL; #ifdef PDF_ENABLE_XFA - FXJSE_Runtime_Release(m_hJSERuntime); + FXJSE_Runtime_Release(m_hJSERuntime, m_bOwnedRuntime); m_hJSERuntime = NULL; FXJSE_Finalize(); @@ -51,12 +52,13 @@ CPDFXFA_App::~CPDFXFA_App() { #endif } -FX_BOOL CPDFXFA_App::Initialize() { +FX_BOOL CPDFXFA_App::Initialize(FXJSE_HRUNTIME hRuntime) { #ifdef PDF_ENABLE_XFA BC_Library_Init(); FXJSE_Initialize(); - m_hJSERuntime = FXJSE_Runtime_Create(); + m_bOwnedRuntime = !hRuntime; + m_hJSERuntime = hRuntime ? hRuntime : FXJSE_Runtime_Create(); if (!m_hJSERuntime) return FALSE; diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index ba6d748ade..95f392487a 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -121,9 +121,7 @@ CJS_Runtime::~CJS_Runtime() { delete m_ContextArray.GetAt(i); m_ContextArray.RemoveAll(); -#ifndef PDF_ENABLE_XFA FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects); -#endif m_pApp = NULL; m_pDocument = NULL; diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index 9b6b5fa445..f015f87136 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -370,11 +370,6 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, return; pData->ReleaseDynamicObjsMap(); -#ifdef PDF_ENABLE_XFA - // XFA, if present, should have already cleaned itself up. - FXSYS_assert(!pData->m_pFXJSERuntimeData); -#endif // PDF_ENABLE_XFA - int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); for (int i = 0; i < maxID; ++i) { CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); diff --git a/xfa/include/fxjse/fxjse.h b/xfa/include/fxjse/fxjse.h index bac63208f8..b8a2af4b8a 100644 --- a/xfa/include/fxjse/fxjse.h +++ b/xfa/include/fxjse/fxjse.h @@ -24,7 +24,7 @@ typedef double FXJSE_DOUBLE; void FXJSE_Initialize(); void FXJSE_Finalize(); FXJSE_HRUNTIME FXJSE_Runtime_Create(); -void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime); +void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime, bool bOwnedRuntime); typedef struct _FXJSE_CLASS FXJSE_CLASS; FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime, const FXJSE_CLASS* lpGlobalClass = nullptr, diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp index 5609c35b63..72e221226d 100644 --- a/xfa/src/fxjse/src/runtime.cpp +++ b/xfa/src/fxjse/src/runtime.cpp @@ -58,12 +58,19 @@ FXJSE_HRUNTIME FXJSE_Runtime_Create() { CFXJSE_RuntimeData::g_RuntimeList->AppendRuntime(pIsolate); return reinterpret_cast<FXJSE_HRUNTIME>(pIsolate); } -void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime) { +void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime, bool bOwnedRuntime) { v8::Isolate* pIsolate = reinterpret_cast<v8::Isolate*>(hRuntime); - if (pIsolate) { + if (!pIsolate) + return; + if (bOwnedRuntime) { ASSERT(CFXJSE_RuntimeData::g_RuntimeList); CFXJSE_RuntimeData::g_RuntimeList->RemoveRuntime( pIsolate, FXJSE_Runtime_DisposeCallback); + } else { + if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) { + delete pData->m_pFXJSERuntimeData; + pData->m_pFXJSERuntimeData = nullptr; + } } } CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) { |