From 2cbae7328b4eb31a78db5babc4d5995971de308f Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 26 Jun 2018 15:11:28 +0000 Subject: Use ObservedPtr for CJS_Field::m_pJSField Bug: 856354 Change-Id: Ic0ac4d189dff6f4688a6c5feb745fe8c5a5ed4bb Reviewed-on: https://pdfium-review.googlesource.com/36150 Commit-Queue: dsinclair Reviewed-by: dsinclair --- fxjs/cjs_document.h | 5 ++--- fxjs/cjs_field.cpp | 4 ++-- fxjs/cjs_field.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h index 262d472cca..2af617f8ad 100644 --- a/fxjs/cjs_document.h +++ b/fxjs/cjs_document.h @@ -11,14 +11,13 @@ #include #include +#include "core/fxcrt/observable.h" #include "fxjs/js_define.h" -class CJS_Document; class CPDF_TextObject; - struct CJS_DelayData; -class CJS_Document : public CJS_Object { +class CJS_Document : public CJS_Object, public Observable { public: static int GetObjDefnID(); static void DefineJSObjects(CFXJS_Engine* pEngine); diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index 84835866ea..6f6455d984 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -205,7 +205,7 @@ void CJS_Field::ParseFieldName(const std::wstring& strFieldNameParsed, bool CJS_Field::AttachField(CJS_Document* pDocument, const WideString& csFieldName) { - m_pJSDoc = pDocument; + m_pJSDoc.Reset(pDocument); m_pFormFillEnv.Reset(pDocument->GetFormFillEnv()); m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || @@ -2467,7 +2467,7 @@ CJS_Return CJS_Field::getArray( auto* pJSField = static_cast(CFXJS_Engine::GetObjectPrivate(pObj)); - pJSField->AttachField(m_pJSDoc, *pStr); + pJSField->AttachField(m_pJSDoc.Get(), *pStr); pRuntime->PutArrayElement(FormFieldArray, j++, pJSField ? v8::Local(pJSField->ToV8Object()) diff --git a/fxjs/cjs_field.h b/fxjs/cjs_field.h index 0f089d0f13..52ddbf70d1 100644 --- a/fxjs/cjs_field.h +++ b/fxjs/cjs_field.h @@ -10,11 +10,11 @@ #include #include +#include "fxjs/cjs_document.h" #include "fxjs/js_define.h" class CPDF_FormControl; class CPDFSDK_Widget; -class CJS_Document; struct CJS_DelayData; enum FIELD_PROP { @@ -418,7 +418,7 @@ class CJS_Field : public CJS_Object { void DoDelay(); - CJS_Document* m_pJSDoc = nullptr; + CJS_Document::ObservedPtr m_pJSDoc; CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv; WideString m_FieldName; int m_nFormControlIndex = -1; -- cgit v1.2.3