diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-11 14:46:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-11 14:46:32 +0000 |
commit | 7d2c5f4c8d33d57b76af1c471e70af36db090072 (patch) | |
tree | 929bc3f0aa098eacd987b6b7f9f8fd077f5cba66 /fxjs/xfa | |
parent | fc77dee8e5d0f941ea6050aa632254b588a21f87 (diff) | |
download | pdfium-7d2c5f4c8d33d57b76af1c471e70af36db090072.tar.xz |
Rename CreateInstance to CreateInstanceIfPossible
This CL makes it clear that CreateInstance may return nullptr.
Change-Id: I82f172a671761eae9055b0e9e55ab0e5a7d599aa
Reviewed-on: https://pdfium-review.googlesource.com/22712
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r-- | fxjs/xfa/cjx_instancemanager.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index a5e3295c9b..d6ac66d9df 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp @@ -77,9 +77,13 @@ int32_t CJX_InstanceManager::SetInstances(int32_t iDesired) { } } else { while (iCount < iDesired) { - CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(true); + CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(true); + if (!pNewInstance) + return 0; + GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); - iCount++; + ++iCount; + CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) return 0; @@ -206,7 +210,10 @@ CJS_Return CJX_InstanceManager::addInstance( if (iMax >= 0 && iCount >= iMax) return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances)); - CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(fFlags); + CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(fFlags); + if (!pNewInstance) + return CJS_Return(runtime->NewNull()); + GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -248,7 +255,10 @@ CJS_Return CJX_InstanceManager::insertInstance( if (iMax >= 0 && iCount >= iMax) return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); - CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(bBind); + CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(bBind); + if (!pNewInstance) + return CJS_Return(runtime->NewNull()); + GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); |