From 0cca568ffe2b5fb8a97e9088ad403eabef7fee37 Mon Sep 17 00:00:00 2001 From: walzer Date: Fri, 28 Sep 2012 18:22:00 +0800 Subject: [PATCH] fixed #1492, assert if user add an CCObject* into CCAutoreleasePool twice. --- cocos2dx/cocoa/CCAutoreleasePool.cpp | 2 ++ cocos2dx/cocoa/CCObject.cpp | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index fae7b822fc..d6583c296f 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -41,6 +41,8 @@ CCAutoreleasePool::~CCAutoreleasePool(void) void CCAutoreleasePool::addObject(CCObject* pObject) { + CCAssert(false == pObject->m_bManaged, "this object is already in autorelese pool"); + m_pManagedObjectArray->addObject(pObject); CCAssert(pObject->m_uReference > 1, "reference count should be greater than 1"); diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index c439c1eda7..8084c65180 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -38,15 +38,13 @@ CCObject* CCCopying::copyWithZone(CCZone *pZone) } CCObject::CCObject(void) +:m_bManaged(false) +,m_uReference(1) // when the object is created, the reference count of it is 1 +,m_nLuaID(0) { static unsigned int uObjectCount = 0; m_uID = ++uObjectCount; - m_nLuaID = 0; - - // when the object is created, the reference count of it is 1 - m_uReference = 1; - m_bManaged = false; } CCObject::~CCObject(void)