diff options
Diffstat (limited to 'core/fxcrt/include/fx_basic.h')
-rw-r--r-- | core/fxcrt/include/fx_basic.h | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 1835d9e0a6..7fdfbf699d 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -717,53 +717,22 @@ class CFX_CountRef { } } - ~CFX_CountRef() { - if (!m_pObject) { - return; - } - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + ~CFX_CountRef() { SetNull(); } ObjClass* New() { - if (m_pObject) { - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + SetNull(); m_pObject = new CountedObj; m_pObject->m_RefCount = 1; return m_pObject; } void operator=(const Ref& ref) { - if (ref.m_pObject) { + if (ref.m_pObject) ref.m_pObject->m_RefCount++; - } - if (m_pObject) { - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + SetNull(); m_pObject = ref.m_pObject; } - void operator=(void* p) { - ASSERT(p == 0); - if (!m_pObject) { - return; - } - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - m_pObject = NULL; - } - const ObjClass* GetObject() const { return m_pObject; } operator const ObjClass*() const { return m_pObject; } |