Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: fpdfsdk/cpdfsdk_baannot.cpp

Issue 2520493002: Make CPDF_Stream() take unique_ptr's to its dictionary. (Closed)
Patch Set: rebase, lint, fix new test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxge/dib/fx_dib_engine_unittest.cpp ('k') | fpdfsdk/formfiller/cba_fontmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/cpdfsdk_baannot.cpp
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 9fb1e88a84b2900b45cf7e829f5abb4b1435a037..3eedf1502c03e1e0298b68e84a93059de282130a 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/cpdfsdk_baannot.h"
#include <algorithm>
+#include <utility>
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
@@ -323,19 +324,16 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
CPDF_Dictionary* pStreamDict = pStream->GetDict();
if (!pStreamDict) {
- pStreamDict =
- new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool());
+ auto pNewDict = pdfium::MakeUnique<CPDF_Dictionary>(
+ m_pAnnot->GetDocument()->GetByteStringPool());
+ pStreamDict = pNewDict.get();
pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject");
pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form");
pStreamDict->SetNewFor<CPDF_Number>("FormType", 1);
- pStream->InitStream(nullptr, 0, pStreamDict);
+ pStream->InitStream(nullptr, 0, std::move(pNewDict));
}
-
- if (pStreamDict) {
- pStreamDict->SetMatrixFor("Matrix", matrix);
- pStreamDict->SetRectFor("BBox", rcBBox);
- }
-
+ pStreamDict->SetMatrixFor("Matrix", matrix);
+ pStreamDict->SetRectFor("BBox", rcBBox);
pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength());
}
« no previous file with comments | « core/fxge/dib/fx_dib_engine_unittest.cpp ('k') | fpdfsdk/formfiller/cba_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698