diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/javascript/Annot.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/javascript/Annot.h | 4 | ||||
-rw-r--r-- | fpdfsdk/javascript/Field.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/javascript/cjs_runtime.cpp | 2 |
5 files changed, 15 insertions, 17 deletions
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp index ec77000449..8e6a775dcd 100644 --- a/fpdfsdk/javascript/Annot.cpp +++ b/fpdfsdk/javascript/Annot.cpp @@ -40,7 +40,7 @@ Annot::~Annot() {} FX_BOOL Annot::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot); + CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); if (!baAnnot) return FALSE; @@ -72,7 +72,7 @@ FX_BOOL Annot::hidden(IJS_Context* cc, FX_BOOL Annot::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { - CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot); + CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); if (!baAnnot) return FALSE; @@ -95,7 +95,7 @@ FX_BOOL Annot::type(IJS_Context* cc, return FALSE; } - CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot); + CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); if (!baAnnot) return FALSE; @@ -104,6 +104,5 @@ FX_BOOL Annot::type(IJS_Context* cc, } void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { - m_pAnnot = annot; - SetWatchedPtr(&m_pAnnot); + m_pAnnot.Reset(annot); } diff --git a/fpdfsdk/javascript/Annot.h b/fpdfsdk/javascript/Annot.h index c8b0afb556..21ad6d017a 100644 --- a/fpdfsdk/javascript/Annot.h +++ b/fpdfsdk/javascript/Annot.h @@ -12,7 +12,7 @@ #include "fpdfsdk/include/cpdfsdk_baannot.h" #include "fpdfsdk/javascript/JS_Define.h" -class Annot : public CJS_EmbedObj, public CPDFSDK_Annot::Observer { +class Annot : public CJS_EmbedObj { public: explicit Annot(CJS_Object* pJSObject); ~Annot() override; @@ -24,7 +24,7 @@ class Annot : public CJS_EmbedObj, public CPDFSDK_Annot::Observer { void SetSDKAnnot(CPDFSDK_BAAnnot* annot); private: - CPDFSDK_Annot* m_pAnnot = nullptr; + CPDFSDK_Annot::ObservedPtr m_pAnnot; }; class CJS_Annot : public CJS_Object { diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 9ecdec6936..85a43d6cb6 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -270,12 +270,12 @@ void Field::UpdateFormField(CPDFSDK_Document* pDocument, if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { for (CPDFSDK_Annot* pAnnot : widgets) { FX_BOOL bFormatted = FALSE; - CPDFSDK_Annot::Observer observer(&pAnnot); + CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); CFX_WideString sValue = - static_cast<CPDFSDK_Widget*>(pAnnot)->OnFormat(bFormatted); - if (pAnnot) { - static_cast<CPDFSDK_Widget*>(pAnnot)->ResetAppearance( - bFormatted ? &sValue : nullptr, FALSE); + static_cast<CPDFSDK_Widget*>(pObserved.Get())->OnFormat(bFormatted); + if (pObserved) { + static_cast<CPDFSDK_Widget*>(pObserved.Get()) + ->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); } } } else { diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index d7086d211e..1e3ea2f04a 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -21,7 +21,7 @@ #include "fpdfsdk/javascript/resource.h" #include "third_party/base/stl_util.h" -class GlobalTimer : public CJS_Runtime::Observer { +class GlobalTimer { public: GlobalTimer(app* pObj, CPDFDoc_Environment* pApp, @@ -38,7 +38,7 @@ class GlobalTimer : public CJS_Runtime::Observer { bool IsOneShot() const { return m_nType == 1; } uint32_t GetTimeOut() const { return m_dwTimeOut; } int GetTimerID() const { return m_nTimerID; } - CJS_Runtime* GetRuntime() const { return m_pRuntime; } + CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } CFX_WideString GetJScript() const { return m_swJScript; } private: @@ -53,7 +53,7 @@ class GlobalTimer : public CJS_Runtime::Observer { const int m_nType; // 0:Interval; 1:TimeOut const uint32_t m_dwTimeOut; const CFX_WideString m_swJScript; - CJS_Runtime* m_pRuntime; + CJS_Runtime::ObservedPtr m_pRuntime; CPDFDoc_Environment* const m_pApp; }; @@ -75,7 +75,6 @@ GlobalTimer::GlobalTimer(app* pObj, CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); m_nTimerID = pHandler->SetTimer(dwElapse, Trigger); (*GetGlobalTimerMap())[m_nTimerID] = this; - SetWatchedPtr(&m_pRuntime); } GlobalTimer::~GlobalTimer() { diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index 67d45d5e4a..bfed82efe1 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -124,7 +124,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) } CJS_Runtime::~CJS_Runtime() { - NotifyObservers(); + NotifyObservedPtrs(); ReleaseEngine(); if (m_isolateManaged) { GetIsolate()->Dispose(); |