summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-20 16:53:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-20 16:53:07 -0700
commitf0a128283aeaeb75ee2f62d0f25ba42ac5b07073 (patch)
tree6f5e89afb22b89211b0eb9e2035190e09f5b13d9 /xfa
parent76852be59cbfdb22901b37bb8579d19c07af7037 (diff)
downloadpdfium-f0a128283aeaeb75ee2f62d0f25ba42ac5b07073.tar.xz
Remove Release() from CFX_Barcode
Review-Url: https://codereview.chromium.org/2000883002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/basewidget/fwl_barcodeimp.cpp32
-rw-r--r--xfa/fwl/basewidget/fwl_barcodeimp.h7
-rw-r--r--xfa/fwl/basewidget/fxmath_barcodeimp.cpp3
-rw-r--r--xfa/fwl/basewidget/fxmath_barcodeimp.h1
4 files changed, 15 insertions, 28 deletions
diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/fwl/basewidget/fwl_barcodeimp.cpp
index 57a3c93e9e..97ade357d3 100644
--- a/xfa/fwl/basewidget/fwl_barcodeimp.cpp
+++ b/xfa/fwl/basewidget/fwl_barcodeimp.cpp
@@ -32,12 +32,10 @@ FX_BOOL IFWL_Barcode::IsProtectedType() {
CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_EditImp(properties, pOuter),
- m_pBarcodeEngine(NULL),
m_dwStatus(0),
m_type(BC_UNKNOWN) {}
-CFWL_BarcodeImp::~CFWL_BarcodeImp() {
- ReleaseBarcodeEngine();
-}
+
+CFWL_BarcodeImp::~CFWL_BarcodeImp() {}
FWL_Error CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Barcode;
@@ -59,7 +57,7 @@ FWL_Error CFWL_BarcodeImp::Initialize() {
FWL_Error CFWL_BarcodeImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
- ReleaseBarcodeEngine();
+ m_pBarcodeEngine.reset();
return CFWL_EditImp::Finalize();
}
FWL_Error CFWL_BarcodeImp::Update() {
@@ -182,29 +180,21 @@ void CFWL_BarcodeImp::CreateBarcodeEngine() {
if (m_pBarcodeEngine || m_type == BC_UNKNOWN)
return;
- m_pBarcodeEngine = new CFX_Barcode;
- if (!m_pBarcodeEngine->Create(m_type)) {
- m_pBarcodeEngine->Release();
- m_pBarcodeEngine = nullptr;
- }
+ std::unique_ptr<CFX_Barcode> pBarcode(new CFX_Barcode);
+ if (pBarcode->Create(m_type))
+ m_pBarcodeEngine = std::move(pBarcode);
}
-void CFWL_BarcodeImp::ReleaseBarcodeEngine() {
- if (m_pBarcodeEngine) {
- m_pBarcodeEngine->Release();
- m_pBarcodeEngine = NULL;
- }
-}
void CFWL_BarcodeImp::SetType(BC_TYPE type) {
- if (m_type == type) {
+ if (m_type == type)
return;
- }
- ReleaseBarcodeEngine();
+
+ m_pBarcodeEngine.reset();
m_type = type;
m_dwStatus = XFA_BCS_NeedUpdate;
}
FWL_Error CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) {
- ReleaseBarcodeEngine();
+ m_pBarcodeEngine.reset();
m_dwStatus = XFA_BCS_NeedUpdate;
return CFWL_EditImp::SetText(wsText);
}
@@ -226,7 +216,7 @@ CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner)
void CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
if (pEvent->GetClassID() == CFWL_EventType::TextChanged) {
CFWL_BarcodeImp* pOwner = static_cast<CFWL_BarcodeImp*>(m_pOwner);
- pOwner->ReleaseBarcodeEngine();
+ pOwner->m_pBarcodeEngine.reset();
pOwner->m_dwStatus = XFA_BCS_NeedUpdate;
}
CFWL_EditImpDelegate::OnProcessEvent(pEvent);
diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.h b/xfa/fwl/basewidget/fwl_barcodeimp.h
index 705329572a..56898bc69e 100644
--- a/xfa/fwl/basewidget/fwl_barcodeimp.h
+++ b/xfa/fwl/basewidget/fwl_barcodeimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_BARCODEIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_BARCODEIMP_H_
+#include <memory>
+
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include "xfa/fwl/basewidget/ifwl_barcode.h"
#include "xfa/fwl/basewidget/ifwl_scrollbar.h"
@@ -43,16 +45,15 @@ class CFWL_BarcodeImp : public CFWL_EditImp {
void GenerateBarcodeImageCache();
void CreateBarcodeEngine();
- void ReleaseBarcodeEngine();
- CFX_Barcode* m_pBarcodeEngine;
+ std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
uint32_t m_dwStatus;
BC_TYPE m_type;
};
class CFWL_BarcodeImpDelegate : public CFWL_EditImpDelegate {
public:
- CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner);
+ explicit CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner);
void OnProcessEvent(CFWL_Event* pEvent) override;
};
diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
index a67952caa6..1dc8afbaef 100644
--- a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
+++ b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
@@ -58,9 +58,6 @@ FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type);
return m_pBCEngine != NULL;
}
-void CFX_Barcode::Release() {
- delete this;
-}
BC_TYPE CFX_Barcode::GetType() {
return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
}
diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.h b/xfa/fwl/basewidget/fxmath_barcodeimp.h
index eca41d05a6..3a2c4b5434 100644
--- a/xfa/fwl/basewidget/fxmath_barcodeimp.h
+++ b/xfa/fwl/basewidget/fxmath_barcodeimp.h
@@ -24,7 +24,6 @@ class CFX_Barcode {
~CFX_Barcode();
FX_BOOL Create(BC_TYPE type);
- void Release();
BC_TYPE GetType();
FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
FX_BOOL RenderDevice(CFX_RenderDevice* device,