mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1827 from folecr/assert_fix
fixed #1654: Assert fix for android.
This commit is contained in:
commit
0fd16e7b31
|
@ -37,7 +37,11 @@ THE SOFTWARE.
|
|||
#ifndef CCAssert
|
||||
#if COCOS2D_DEBUG > 0
|
||||
extern void CC_DLL cc_assert_script_compatible(bool cond, const char *msg);
|
||||
#define CCAssert(cond, msg) cc_assert_script_compatible(!!(cond), (msg))
|
||||
#define CCAssert(cond, msg) \
|
||||
{ \
|
||||
cc_assert_script_compatible(!!(cond), (msg)); \
|
||||
CC_ASSERT(cond); \
|
||||
}
|
||||
#else
|
||||
#define CCAssert(cond, msg)
|
||||
#endif
|
||||
|
|
|
@ -17,13 +17,13 @@ CCApplication * CCApplication::sm_pSharedApplication = 0;
|
|||
|
||||
CCApplication::CCApplication()
|
||||
{
|
||||
CC_ASSERT(! sm_pSharedApplication);
|
||||
CCAssert(! sm_pSharedApplication, "");
|
||||
sm_pSharedApplication = this;
|
||||
}
|
||||
|
||||
CCApplication::~CCApplication()
|
||||
{
|
||||
CC_ASSERT(this == sm_pSharedApplication);
|
||||
CCAssert(this == sm_pSharedApplication, "");
|
||||
sm_pSharedApplication = NULL;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ CCApplication::Orientation CCApplication::setOrientation(Orientation orientation
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
CCApplication* CCApplication::sharedApplication()
|
||||
{
|
||||
CC_ASSERT(sm_pSharedApplication);
|
||||
CCAssert(sm_pSharedApplication, "");
|
||||
return sm_pSharedApplication;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "android/log.h"
|
||||
|
||||
#define CC_DLL
|
||||
|
||||
#define CC_ASSERT(cond) \
|
||||
if (! (cond)) \
|
||||
{ \
|
||||
char content[256]; \
|
||||
sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__); \
|
||||
cocos2d::CCMessageBox(content, "Assert error"); \
|
||||
#define CC_NO_MESSAGE_PSEUDOASSERT(cond) \
|
||||
if (!(cond)) { \
|
||||
__android_log_print(ANDROID_LOG_ERROR, \
|
||||
"cocos2d-x assert", \
|
||||
"%s function:%s line:%d", \
|
||||
__FILE__, __FUNCTION__, __LINE__); \
|
||||
}
|
||||
|
||||
#define CC_MESSAGE_PSEUDOASSERT(cond, msg) \
|
||||
if (!(cond)) { \
|
||||
__android_log_print(ANDROID_LOG_ERROR, \
|
||||
"cocos2d-x assert", \
|
||||
"file:%s function:%s line:%d, %s", \
|
||||
__FILE__, __FUNCTION__, __LINE__, msg); \
|
||||
}
|
||||
|
||||
#define CC_ASSERT(cond) CC_NO_MESSAGE_PSEUDOASSERT(cond)
|
||||
|
||||
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
||||
|
||||
|
@ -23,6 +34,4 @@ if (! (cond)) \
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -32,8 +32,6 @@ void CC_DLL cc_assert_script_compatible(bool cond, const char *msg)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CC_ASSERT(cond);
|
||||
}
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -398,7 +398,7 @@ CCHttpClient* CCHttpClient::getInstance()
|
|||
|
||||
void CCHttpClient::destroyInstance()
|
||||
{
|
||||
CC_ASSERT(s_pHttpClient);
|
||||
CCAssert(s_pHttpClient, "");
|
||||
CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CCHttpClient::dispatchResponseCallbacks), s_pHttpClient);
|
||||
s_pHttpClient->release();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue