We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
CCTouchScriptHandlerEntry will release twice lua reference
CCTouchScriptHandlerEntry will release twice lua reference
Bug #2535 [Closed]
fixed in quick-cocos2d-x, see https://github.com/dualface/quick-cocos2d-x/commit/ae40c9b6b91179aa98687bf5f2cfd64f0eb3c85a
Status: | Closed | |
---|---|---|
Start date: | 2013-08-18 | |
Priority: | High | |
Due date: | ||
Assignee: | - | |
% Done: | 100% |
|
Category: | lua | |
Target version: | - |
In CCScriptSupport.cpp
CCTouchScriptHandlerEntry::~CCTouchScriptHandlerEntry(void)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nHandler);
LUALOG("[LUA] Remove touch event handler: %d", m_nHandler);
}
the CCTouchScriptHandlerEntry parent class is CCScriptHandlerEntry:
CCScriptHandlerEntry::~CCScriptHandlerEntry(void)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nHandler);
}
when CCTouchScriptHandlerEntry is destructed ,the nHandler will be twice call “removeScriptHandler”, and lua virtual machine maybe crashed.
it should be fixed as below:
`CCScriptHandlerEntry::~CCScriptHandlerEntry(void)
{
if (m_nHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nHandler);
m_nHandler=0;
}
}
CCTouchScriptHandlerEntry::~CCTouchScriptHandlerEntry(void)
{
if (m_nHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nHandler);
m_nHandler=0;
LUALOG("[LUA] Remove touch event handler: %d", m_nHandler);
}
}
`