From e7d7ff99c7633bcb47ce3fe3cba7e46cc4e4c3d6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Jul 2012 11:21:08 +0800 Subject: [PATCH] fixed #1386: PauseResumeActionsTest crashes. --- .../Classes/ActionsTest/ActionsTest.cpp | 19 +++++++++++++++++-- .../TestCpp/Classes/ActionsTest/ActionsTest.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp index a6cac8819f..7871b416e9 100644 --- a/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -1628,6 +1628,18 @@ string ActionCardinalSpline::subtitle() /** PauseResumeActions */ + +PauseResumeActions::PauseResumeActions() +: m_pPausedTargets(NULL) +{ + +} + +PauseResumeActions::~PauseResumeActions() +{ + CC_SAFE_RELEASE(m_pPausedTargets); +} + void PauseResumeActions::onEnter() { ActionsDemo::onEnter(); @@ -1656,12 +1668,15 @@ void PauseResumeActions::pause(float dt) { CCLog("Pausing"); CCDirector *director = CCDirector::sharedDirector(); - this->m_pPausedTargets = director->getActionManager()->pauseAllRunningActions(); + + CC_SAFE_RELEASE(m_pPausedTargets); + m_pPausedTargets = director->getActionManager()->pauseAllRunningActions(); + CC_SAFE_RETAIN(m_pPausedTargets); } void PauseResumeActions::resume(float dt) { CCLog("Resuming"); CCDirector *director = CCDirector::sharedDirector(); - director->getActionManager()->resumeTargets(this->m_pPausedTargets); + director->getActionManager()->resumeTargets(m_pPausedTargets); } diff --git a/samples/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/TestCpp/Classes/ActionsTest/ActionsTest.h index 3267b1d2fa..ed79365238 100644 --- a/samples/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -367,6 +367,8 @@ private: class PauseResumeActions : public ActionsDemo { public: + PauseResumeActions(); + virtual ~PauseResumeActions(); virtual void onEnter(); virtual std::string subtitle(); virtual std::string title();