From 7d2a8d966643ebc77c1aa0f0c53a0ffd2d681c4c Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 8 Jun 2016 11:51:23 -0700 Subject: Remove implicit CFX_CountedRef::operator T*() Explicitly invoke GetObject() method instead. This avoids having code where it looks like non-pointers are assigned to pointers but works due to the cast operator. Review-Url: https://codereview.chromium.org/2045083003 --- core/fxcrt/include/fx_basic.h | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 8e39f5577a..bc05a3479d 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -648,27 +648,24 @@ class CFX_BitStream { const uint8_t* m_pData; }; + template class CFX_CountRef { public: - typedef CFX_CountRef Ref; + using Ref = CFX_CountRef; class CountedObj : public ObjClass { public: CountedObj() {} - CountedObj(const CountedObj& src) : ObjClass(src) {} int m_RefCount; }; - CFX_CountRef() { m_pObject = nullptr; } - - CFX_CountRef(const Ref& ref) { - m_pObject = ref.m_pObject; - if (m_pObject) { + CFX_CountRef() : m_pObject(nullptr) {} + CFX_CountRef(const Ref& ref) : m_pObject(ref.m_pObject) { + if (m_pObject) m_pObject->m_RefCount++; - } } ~CFX_CountRef() { SetNull(); } @@ -687,14 +684,10 @@ class CFX_CountRef { m_pObject = ref.m_pObject; } - const ObjClass* GetObject() const { return m_pObject; } - - operator const ObjClass*() const { return m_pObject; } - - FX_BOOL IsNull() const { return !m_pObject; } - - FX_BOOL NotNull() const { return !IsNull(); } + bool IsNull() const { return !m_pObject; } + bool NotNull() const { return !IsNull(); } + const ObjClass* GetObject() const { return m_pObject; } ObjClass* GetModify() { if (!m_pObject) { m_pObject = new CountedObj; @@ -724,6 +717,7 @@ class CFX_CountRef { protected: CountedObj* m_pObject; }; + class IFX_Pause { public: virtual ~IFX_Pause() {} -- cgit v1.2.3