summaryrefslogtreecommitdiff
path: root/xfa/fwl/theme
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-08-10 14:50:48 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-10 14:50:48 -0700
commitb4d1b576bccb5ca6cebe29288af014bd0f512af1 (patch)
tree2d60839a8323eb6780c782aba4ae1123243c7355 /xfa/fwl/theme
parent1194561d5d83869edecf6a1f402122a59955f0b7 (diff)
downloadpdfium-b4d1b576bccb5ca6cebe29288af014bd0f512af1.tar.xz
Use smart pointers for class owned pointers in xfa/fxfa
Use smart pointers instead of raw pointer to make memory management easier for classes mainly under xfa/fxfa. Also change the return type of IFGAS_FontMgr::Create() to smart pointer type. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2227883002
Diffstat (limited to 'xfa/fwl/theme')
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp34
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.h9
2 files changed, 11 insertions, 32 deletions
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index 9960257730..b5658cf7b2 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -697,31 +697,9 @@ CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(nullptr) {
SetColorData(0);
}
-CFWL_FontData::CFWL_FontData()
- : m_dwStyles(0),
- m_dwCodePage(0),
- m_pFont(0),
- m_pFontMgr(nullptr)
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- ,
- m_pFontSource(nullptr)
-#endif
-{
-}
+CFWL_FontData::CFWL_FontData() : m_dwStyles(0), m_dwCodePage(0) {}
-CFWL_FontData::~CFWL_FontData() {
- if (m_pFont) {
- m_pFont->Release();
- }
- if (m_pFontMgr) {
- m_pFontMgr->Release();
- }
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- if (m_pFontSource) {
- m_pFontSource->Release();
- }
-#endif
-}
+CFWL_FontData::~CFWL_FontData() {}
FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
@@ -740,12 +718,12 @@ FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
m_pFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource = new CFX_FontSourceEnum_File;
- m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource);
+ m_pFontSource.reset(new CFX_FontSourceEnum_File);
+ m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
- m_pFont = CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
- dwCodePage, m_pFontMgr);
+ m_pFont.reset(CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
+ dwCodePage, m_pFontMgr.get()));
return !!m_pFont;
}
diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h
index 8a1e0c152a..e6d09326c2 100644
--- a/xfa/fwl/theme/cfwl_widgettp.h
+++ b/xfa/fwl/theme/cfwl_widgettp.h
@@ -236,23 +236,24 @@ class CFWL_FontData {
public:
CFWL_FontData();
virtual ~CFWL_FontData();
+
FX_BOOL Equal(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage);
FX_BOOL LoadFont(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage);
- CFGAS_GEFont* GetFont() const { return m_pFont; }
+ CFGAS_GEFont* GetFont() const { return m_pFont.get(); }
protected:
CFX_WideString m_wsFamily;
uint32_t m_dwStyles;
uint32_t m_dwCodePage;
- CFGAS_GEFont* m_pFont;
- IFGAS_FontMgr* m_pFontMgr;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- CFX_FontSourceEnum_File* m_pFontSource;
+ std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource;
#endif
+ std::unique_ptr<IFGAS_FontMgr> m_pFontMgr;
+ std::unique_ptr<CFGAS_GEFont> m_pFont;
};
class CFWL_FontManager {