summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp10
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h4
2 files changed, 12 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index ed58d24b1f..84fcb37d16 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -73,8 +73,16 @@ void CPDFXFA_Context::SetFormFillEnv(
// The layout data can have pointers back into the script context. That
// context will be different if the form fill environment closes, so, force
// the layout data to clear.
- if (m_pXFADoc && m_pXFADoc->GetXFADoc())
+ if (m_pXFADoc && m_pXFADoc->GetXFADoc()) {
+ // The CPDF_XFADocView has a pointer to the CXFA_LayoutProcessor which is
+ // owned by the CXFA_Document. The Layout Processor will be freed with the
+ // ClearLayoutData() call. Make sure the doc view has already released the
+ // pointer.
+ if (m_pXFADocView)
+ m_pXFADocView->ResetLayoutProcessor();
+
m_pXFADoc->GetXFADoc()->ClearLayoutData();
+ }
m_pFormFillEnv.Reset(pFormFillEnv);
}
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index 2b8358264c..efa504ecd3 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -97,6 +97,8 @@ class CXFA_FFDocView {
bool m_bInLayoutStatus = false;
std::vector<WideString> m_arrNullTestMsg;
+ void ResetLayoutProcessor() { m_pXFADocLayout.Release(); }
+
private:
bool RunEventLayoutReady();
void RunBindItems();
@@ -115,7 +117,7 @@ class CXFA_FFDocView {
UnownedPtr<CXFA_FFDoc> const m_pDoc;
std::unique_ptr<CXFA_FFWidgetHandler> m_pWidgetHandler;
- CXFA_LayoutProcessor* m_pXFADocLayout = nullptr; // Not owned.
+ UnownedPtr<CXFA_LayoutProcessor> m_pXFADocLayout;
UnownedPtr<CXFA_Node> m_pFocusNode;
UnownedPtr<CXFA_FFWidget> m_pFocusWidget;
std::vector<CXFA_Node*> m_ValidateNodes;