From 4b9d69806c30775f55563e72b0842daa06483f99 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 26 Jan 2018 17:11:51 +0000 Subject: Clean up construction of CFX_Barcode Because certain enum values can cause the initialization of the class to fail there is a seperate init method from the constructor. This CL is converting the code to use a standard factory pattern for this, instead of the existing implementation. Change-Id: Ia2293ce94ad0db5862db9796aeb8a224fd2b45f9 Reviewed-on: https://pdfium-review.googlesource.com/24230 Reviewed-by: Henrique Nakashima Commit-Queue: Ryan Harrison --- xfa/fwl/cfx_barcode.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'xfa/fwl/cfx_barcode.cpp') diff --git a/xfa/fwl/cfx_barcode.cpp b/xfa/fwl/cfx_barcode.cpp index 9d667c67b9..2d1253630e 100644 --- a/xfa/fwl/cfx_barcode.cpp +++ b/xfa/fwl/cfx_barcode.cpp @@ -59,9 +59,11 @@ CFX_Barcode::CFX_Barcode() {} CFX_Barcode::~CFX_Barcode() {} -bool CFX_Barcode::Create(BC_TYPE type) { - m_pBCEngine = CreateBarCodeEngineObject(type); - return !!m_pBCEngine; +std::unique_ptr CFX_Barcode::Create(BC_TYPE type) { + auto barcodeEngine = CreateBarCodeEngineObject(type); + std::unique_ptr barcode(new CFX_Barcode()); + barcode->m_pBCEngine.swap(barcodeEngine); + return barcode; } BC_TYPE CFX_Barcode::GetType() { -- cgit v1.2.3