Set the view pointer as NULL after its xfa doc is released
authorJun Fang <jun_fang@foxitsoftware.com>
Tue, 17 Feb 2015 12:52:09 +0000 (04:52 -0800)
committerJun Fang <jun_fang@foxitsoftware.com>
Tue, 17 Feb 2015 12:52:09 +0000 (04:52 -0800)
BUG=452794
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/928803002

fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp

index fadded8..317200c 100644 (file)
@@ -14,6 +14,7 @@ class CPDFSDK_Document;
 class CPDFDoc_Environment;\r
 class IFXJS_Runtime;\r
 class IFXJS_Context;\r
+class IXFA_DocHandler;\r
 \r
 class CPDFXFA_Document : public IXFA_DocProvider, public CFX_Object\r
 {\r
@@ -22,7 +23,6 @@ public:
        ~CPDFXFA_Document();\r
 \r
        FX_BOOL                         LoadXFADoc();\r
-       void                            CloseXFADoc();\r
        CPDFXFA_App*            GetApp() {return m_pApp;}\r
        CPDF_Document*          GetPDFDoc() { return m_pPDFDoc; }\r
        XFA_HDOC                        GetXFADoc() { return m_pXFADoc; }\r
@@ -128,6 +128,15 @@ public:
        void            _ClearChangeMark();\r
 \r
 private:\r
+       void            CloseXFADoc(IXFA_DocHandler* pDoc) {\r
+                                       if (pDoc) {\r
+                                               pDoc->CloseDoc(m_pXFADoc);\r
+                                               pDoc->ReleaseDoc(m_pXFADoc);\r
+                                               m_pXFADoc = NULL;\r
+                                               m_pXFADocView = NULL;\r
+                                       }\r
+                               }\r
+\r
        CPDF_Document* m_pPDFDoc;\r
        XFA_HDOC  m_pXFADoc;\r
        IXFA_DocView* m_pXFADocView;\r
index d8c08cc..f138706 100644 (file)
 #include "../../include/fpdfxfa/fpdfxfa_page.h"\r
 #include "../../include/javascript/IJavaScript.h"\r
 \r
-\r
-\r
-#define IDS_XFA_StringMonth_April "April"\r
-#define IDS_XFA_StringMonth_May "May"\r
-#define IDS_XFA_StringMonth_June "June"\r
-#define IDS_XFA_StringMonth_July "July"\r
-#define IDS_XFA_StringMonth_Aug "August"\r
-#define IDS_XFA_StringMonth_Sept "September"\r
-#define IDS_XFA_StringMonth_Oct "October"\r
-#define IDS_XFA_StringMonth_Nov "November"\r
-#define IDS_XFA_StringMonth_Dec "December"\r
-#define IDS_XFA_String_Today    "Today"\r
-#define IDS_XFA_ValidateLimit   "Message limit exceeded. Remaining %d validation errors not reported."\r
 #define IDS_XFA_Validate_Input  "At least one required field was empty. Please fill in the required fields\r\n(highlighted) before continuing."\r
 \r
 // submit\r
@@ -78,9 +65,7 @@ CPDFXFA_Document::~CPDFXFA_Document()
                        IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();\r
                        if (pDocHandler)\r
                        {\r
-                               pDocHandler->CloseDoc(m_pXFADoc);\r
-                               pDocHandler->ReleaseDoc(m_pXFADoc);\r
-                               m_pXFADoc = NULL;\r
+                               CloseXFADoc(pDocHandler);\r
                        }       \r
                }\r
        }\r
@@ -129,10 +114,7 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc()
                                iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL);\r
                                if (iStatus != 100) \r
                                {\r
-                                       pDocHandler->CloseDoc(m_pXFADoc);\r
-                                       pDocHandler->ReleaseDoc(m_pXFADoc);\r
-                                       m_pXFADoc = NULL;\r
-\r
+                                       CloseXFADoc(pDocHandler);\r
                                        SetLastError(FPDF_ERR_XFALOAD);\r
                                        return FALSE;\r
                                }\r
@@ -149,10 +131,7 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc()
 \r
                                if (m_pXFADocView->StartLayout() < 0) \r
                                {\r
-                                       pDocHandler->CloseDoc(m_pXFADoc);\r
-                                       pDocHandler->ReleaseDoc(m_pXFADoc);\r
-                                       m_pXFADoc = NULL;\r
-\r
+                                       CloseXFADoc(pDocHandler);\r
                                        SetLastError(FPDF_ERR_XFALAYOUT);\r
                                        return FALSE;\r
                                }\r