summaryrefslogtreecommitdiff
path: root/core/fxge/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/android')
-rw-r--r--core/fxge/android/cfpf_skiadevicemodule.cpp18
-rw-r--r--core/fxge/android/cfpf_skiadevicemodule.h6
2 files changed, 14 insertions, 10 deletions
diff --git a/core/fxge/android/cfpf_skiadevicemodule.cpp b/core/fxge/android/cfpf_skiadevicemodule.cpp
index 7bdf64666f..bb3f70afa1 100644
--- a/core/fxge/android/cfpf_skiadevicemodule.cpp
+++ b/core/fxge/android/cfpf_skiadevicemodule.cpp
@@ -6,7 +6,10 @@
#include "core/fxge/android/cfpf_skiadevicemodule.h"
+#include <utility>
+
#include "core/fxge/android/cfpf_skiafontmgr.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -20,9 +23,9 @@ CFPF_SkiaDeviceModule* CFPF_GetSkiaDeviceModule() {
return gs_pPFModule;
}
-CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() {
- delete m_pFontMgr;
-}
+CFPF_SkiaDeviceModule::CFPF_SkiaDeviceModule() {}
+
+CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() {}
void CFPF_SkiaDeviceModule::Destroy() {
delete gs_pPFModule;
@@ -31,11 +34,10 @@ void CFPF_SkiaDeviceModule::Destroy() {
CFPF_SkiaFontMgr* CFPF_SkiaDeviceModule::GetFontMgr() {
if (!m_pFontMgr) {
- m_pFontMgr = new CFPF_SkiaFontMgr;
- if (!m_pFontMgr->InitFTLibrary()) {
- delete m_pFontMgr;
+ auto pNewMgr = pdfium::MakeUnique<CFPF_SkiaFontMgr>();
+ if (!pNewMgr->InitFTLibrary())
return nullptr;
- }
+ m_pFontMgr = std::move(pNewMgr);
}
- return m_pFontMgr;
+ return m_pFontMgr.get();
}
diff --git a/core/fxge/android/cfpf_skiadevicemodule.h b/core/fxge/android/cfpf_skiadevicemodule.h
index 3261820039..558b08413d 100644
--- a/core/fxge/android/cfpf_skiadevicemodule.h
+++ b/core/fxge/android/cfpf_skiadevicemodule.h
@@ -7,18 +7,20 @@
#ifndef CORE_FXGE_ANDROID_CFPF_SKIADEVICEMODULE_H_
#define CORE_FXGE_ANDROID_CFPF_SKIADEVICEMODULE_H_
+#include <memory>
+
class CFPF_SkiaFontMgr;
class CFPF_SkiaDeviceModule {
public:
- CFPF_SkiaDeviceModule() : m_pFontMgr(nullptr) {}
+ CFPF_SkiaDeviceModule();
~CFPF_SkiaDeviceModule();
void Destroy();
CFPF_SkiaFontMgr* GetFontMgr();
protected:
- CFPF_SkiaFontMgr* m_pFontMgr;
+ std::unique_ptr<CFPF_SkiaFontMgr> m_pFontMgr;
};
CFPF_SkiaDeviceModule* CFPF_GetSkiaDeviceModule();