Skip to content

Commit 774c886

Browse files
author
Walzer
committed
issue cocos2d#175, add retain for CCCallFunc::m_pSelectorTarget
1 parent e187708 commit 774c886

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cocos2dx/actions/CCInstantAction.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ namespace cocos2d {
269269
}
270270
bool CCCallFunc::initWithTarget(SelectorProtocol* pSelectorTarget)
271271
{
272+
if (pSelectorTarget)
273+
{
274+
pSelectorTarget->selectorProtocolRetain();
275+
}
276+
if (m_pSelectorTarget)
277+
{
278+
m_pSelectorTarget->selectorProtocolRelease();
279+
}
272280
m_pSelectorTarget = pSelectorTarget;
273281
return true;
274282
}

cocos2dx/include/CCInstantAction.h

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ namespace cocos2d {
172172
}
173173
virtual ~CCCallFunc()
174174
{
175+
if (m_pSelectorTarget)
176+
{
177+
m_pSelectorTarget->selectorProtocolRelease();
178+
}
175179
}
176180
/** creates the action with the callback
177181

0 commit comments

Comments
 (0)