diff options
author | Oliver Chang <ochang@chromium.org> | 2015-10-30 15:28:47 -0700 |
---|---|---|
committer | Oliver Chang <ochang@chromium.org> | 2015-10-30 15:28:47 -0700 |
commit | 34c509e0e0fbd64d4380f130c48434b07f60b69e (patch) | |
tree | addd5543aae6edbc266fa93d43e89f162b2f5a77 | |
parent | 81edc51ef8242205c5a1192bc33bf16d8c96120b (diff) | |
download | pdfium-34c509e0e0fbd64d4380f130c48434b07f60b69e.tar.xz |
Convert a bunch of raw pointers in fsdk_mgr to unique_ptrs.
R=tsepez@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/1425233002 .
-rw-r--r-- | fpdfsdk/include/fsdk_mgr.h | 14 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 52 |
2 files changed, 20 insertions, 46 deletions
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 2cc528265d..ae4e16368c 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -205,7 +205,7 @@ class CPDFDoc_Environment final { CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } CPDF_Document* GetPDFDocument() const { return m_pPDFDoc; } CFX_ByteString GetAppName() const { return ""; } - IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler; } + IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } CFFL_IFormFiller* GetIFormFiller(); // Creates if not present. @@ -214,14 +214,14 @@ class CPDFDoc_Environment final { CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. private: - CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; - CPDFSDK_ActionHandler* m_pActionHandler; + nonstd::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; + nonstd::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; nonstd::unique_ptr<IJS_Runtime> m_pJSRuntime; FPDF_FORMFILLINFO* const m_pInfo; CPDFSDK_Document* m_pSDKDoc; CPDF_Document* const m_pPDFDoc; - CFFL_IFormFiller* m_pIFormFiller; - IFX_SystemHandler* m_pSysHandler; + nonstd::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; + nonstd::unique_ptr<IFX_SystemHandler> m_pSysHandler; }; class CPDFSDK_Document { @@ -278,10 +278,10 @@ class CPDFSDK_Document { private: std::map<CPDF_Page*, CPDFSDK_PageView*> m_pageMap; CPDF_Document* m_pDoc; - CPDFSDK_InterForm* m_pInterForm; + nonstd::unique_ptr<CPDFSDK_InterForm> m_pInterForm; CPDFSDK_Annot* m_pFocusAnnot; CPDFDoc_Environment* m_pEnv; - CPDF_OCContext* m_pOccontent; + nonstd::unique_ptr<CPDF_OCContext> m_pOccontent; FX_BOOL m_bChangeMask; FX_BOOL m_bBeingDestroyed; }; diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 60fd0eff0b..841bd197e0 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -210,27 +210,13 @@ FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() { CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo) - : m_pAnnotHandlerMgr(NULL), - m_pActionHandler(NULL), - m_pInfo(pFFinfo), + : m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pPDFDoc(pDoc), - m_pIFormFiller(NULL) { - m_pSysHandler = new CFX_SystemHandler(this); + m_pSysHandler(new CFX_SystemHandler(this)) { } CPDFDoc_Environment::~CPDFDoc_Environment() { - delete m_pIFormFiller; - m_pIFormFiller = NULL; - - delete m_pSysHandler; - m_pSysHandler = NULL; - - delete m_pAnnotHandlerMgr; - m_pAnnotHandlerMgr = NULL; - - delete m_pActionHandler; - m_pActionHandler = NULL; } int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, @@ -385,31 +371,25 @@ IJS_Runtime* CPDFDoc_Environment::GetJSRuntime() { CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() { if (!m_pAnnotHandlerMgr) - m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this); - return m_pAnnotHandlerMgr; + m_pAnnotHandlerMgr.reset(new CPDFSDK_AnnotHandlerMgr(this)); + return m_pAnnotHandlerMgr.get(); } CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() { if (!m_pActionHandler) - m_pActionHandler = new CPDFSDK_ActionHandler(); - return m_pActionHandler; + m_pActionHandler.reset(new CPDFSDK_ActionHandler()); + return m_pActionHandler.get(); } CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller() { if (!m_pIFormFiller) - m_pIFormFiller = new CFFL_IFormFiller(this); - return m_pIFormFiller; + m_pIFormFiller.reset(new CFFL_IFormFiller(this)); + return m_pIFormFiller.get(); } CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv) - : m_pDoc(pDoc), - m_pInterForm(nullptr), - m_pFocusAnnot(nullptr), - m_pEnv(pEnv), - m_pOccontent(nullptr), - m_bChangeMask(FALSE), - m_bBeingDestroyed(FALSE) { + : m_pDoc(pDoc), m_pFocusAnnot(nullptr), m_pEnv(pEnv), m_bChangeMask(FALSE) { } CPDFSDK_Document::~CPDFSDK_Document() { @@ -421,12 +401,6 @@ CPDFSDK_Document::~CPDFSDK_Document() { for (auto& it : m_pageMap) delete it.second; m_pageMap.clear(); - - delete m_pInterForm; - m_pInterForm = nullptr; - - delete m_pOccontent; - m_pOccontent = nullptr; } CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, @@ -503,8 +477,8 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() { CPDF_OCContext* CPDFSDK_Document::GetOCContext() { if (!m_pOccontent) - m_pOccontent = new CPDF_OCContext(m_pDoc); - return m_pOccontent; + m_pOccontent.reset(new CPDF_OCContext(m_pDoc)); + return m_pOccontent.get(); } void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) { @@ -530,8 +504,8 @@ CPDF_Page* CPDFSDK_Document::GetPage(int nIndex) { CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { if (!m_pInterForm) - m_pInterForm = new CPDFSDK_InterForm(this); - return m_pInterForm; + m_pInterForm.reset(new CPDFSDK_InterForm(this)); + return m_pInterForm.get(); } void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, |