mirror of https://github.com/axmolengine/axmol.git
[Mac] fix CC_ASSERT error
[Mac] add CC_DISABLE_ASSERT check [cocos2d-x] CCSprite::createWithSpriteFrame() check pSpriteFrame
This commit is contained in:
parent
dcc8733a53
commit
39b019b2cb
|
@ -36,13 +36,13 @@ CCApplication* CCApplication::sm_pSharedApplication = 0;
|
||||||
|
|
||||||
CCApplication::CCApplication()
|
CCApplication::CCApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(! sm_pSharedApplication);
|
CCAssert(! sm_pSharedApplication, "sm_pSharedApplication already exist");
|
||||||
sm_pSharedApplication = this;
|
sm_pSharedApplication = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::~CCApplication()
|
CCApplication::~CCApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(this == sm_pSharedApplication);
|
CCAssert(this == sm_pSharedApplication, "sm_pSharedApplication != this");
|
||||||
sm_pSharedApplication = 0;
|
sm_pSharedApplication = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ TargetPlatform CCApplication::getTargetPlatform()
|
||||||
|
|
||||||
CCApplication* CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CCAssert(sm_pSharedApplication, "sm_pSharedApplication not set");
|
||||||
return sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,8 +340,8 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
||||||
CCAssert( pText, @"Invalid pText");
|
CCAssert(pText, "Invalid pText");
|
||||||
CCAssert( pInfo, @"Invalid pInfo");
|
CCAssert(pInfo, "Invalid pInfo");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
NSString * string = [NSString stringWithUTF8String:pText];
|
NSString * string = [NSString stringWithUTF8String:pText];
|
||||||
|
|
|
@ -5,8 +5,11 @@
|
||||||
|
|
||||||
#define CC_DLL
|
#define CC_DLL
|
||||||
|
|
||||||
|
#if CC_DISABLE_ASSERT > 0
|
||||||
|
#define CC_ASSERT(cond)
|
||||||
|
#else
|
||||||
#define CC_ASSERT(cond) assert(cond)
|
#define CC_ASSERT(cond) assert(cond)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
||||||
CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
||||||
{
|
{
|
||||||
CCSprite *pobSprite = new CCSprite();
|
CCSprite *pobSprite = new CCSprite();
|
||||||
if (pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
|
if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
|
||||||
{
|
{
|
||||||
pobSprite->autorelease();
|
pobSprite->autorelease();
|
||||||
return pobSprite;
|
return pobSprite;
|
||||||
|
@ -153,9 +153,12 @@ CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||||
{
|
{
|
||||||
CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);
|
CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG > 0
|
||||||
char msg[256] = {0};
|
char msg[256] = {0};
|
||||||
sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName);
|
sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName);
|
||||||
CCAssert(pFrame != NULL, msg);
|
CCAssert(pFrame != NULL, msg);
|
||||||
|
#endif
|
||||||
|
|
||||||
return createWithSpriteFrame(pFrame);
|
return createWithSpriteFrame(pFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue