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

Unified Diff: xfa/fgas/font/fgas_gefont.cpp

Issue 2207093005: Use smart pointers for class owned pointers (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: small fix Created 4 years, 4 months 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
Index: xfa/fgas/font/fgas_gefont.cpp
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index 48635cabf7b324c5f018b8f9cd57521349305e28..809684eb2261735c32b67032e85228ea50738e4f 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -77,12 +77,6 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
m_pFontMgr(pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
}
@@ -96,12 +90,6 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles)
m_pFontMgr(src.m_pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
ASSERT(src.m_pFont);
m_pFont = new CFX_Font;
@@ -125,16 +113,7 @@ CFGAS_GEFont::~CFGAS_GEFont() {
m_SubstFonts.RemoveAll();
m_FontMapper.clear();
- if (m_pFileRead)
- m_pFileRead->Release();
- if (m_pStream)
- m_pStream->Release();
-
- delete m_pFontEncoding;
- delete m_pCharWidthMap;
- delete m_pRectArray;
- delete m_pBBoxMap;
if (!m_bExtFont)
delete m_pFont;
}
@@ -213,22 +192,19 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
FX_BOOL bSaveStream) {
- if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
+ if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
return FALSE;
- }
- if (bSaveStream) {
- m_pStream = pFontStream;
- }
- m_pFileRead = FX_CreateFileRead(pFontStream, FALSE);
+ if (bSaveStream)
+ m_pStream.reset(pFontStream);
+
+ m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE));
m_pFont = new CFX_Font;
- FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead);
- if (bRet) {
- bRet = InitFont();
+ if (m_pFont->LoadFile(m_pFileRead.get())) {
+ return InitFont();
} else {
Lei Zhang 2016/08/04 18:49:31 no else after return
Wei Li 2016/08/04 22:16:04 Done.
- m_pFileRead->Release();
- m_pFileRead = nullptr;
+ m_pFileRead.reset();
+ return FALSE;
}
- return bRet;
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -245,16 +221,16 @@ FX_BOOL CFGAS_GEFont::InitFont() {
if (!m_pFont)
return FALSE;
if (!m_pFontEncoding) {
- m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont);
+ m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont));
if (!m_pFontEncoding)
return FALSE;
}
if (!m_pCharWidthMap)
- m_pCharWidthMap = new CFX_DiscreteArrayTemplate<uint16_t>(1024);
+ m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024));
if (!m_pRectArray)
- m_pRectArray = new CFX_MassArrayTemplate<CFX_Rect>(16);
+ m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16));
if (!m_pBBoxMap)
- m_pBBoxMap = new CFX_MapPtrToPtr(16);
+ m_pBBoxMap.reset(new CFX_MapPtrToPtr(16));
return TRUE;
}

Powered by Google App Engine
This is Rietveld 408576698