From 0840baa1abad23c216785486f1875baa08ef757f Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 22 Sep 2013 22:49:25 +0800 Subject: [PATCH 1/4] retan ActionNode _actionSpawn while create --- extensions/CocoStudio/Action/CCActionNode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/CocoStudio/Action/CCActionNode.cpp b/extensions/CocoStudio/Action/CCActionNode.cpp index f14add6211..3972d5bfb0 100644 --- a/extensions/CocoStudio/Action/CCActionNode.cpp +++ b/extensions/CocoStudio/Action/CCActionNode.cpp @@ -313,6 +313,7 @@ Spawn * ActionNode::refreshActionProperty() } _actionSpawn = Spawn::create(cSpawnArray); + _actionSpawn->retain(); return _actionSpawn; } From e8cf0a1485ef801920de6320f47d41f9c2c49586 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 22 Sep 2013 23:55:12 +0800 Subject: [PATCH 2/4] add judgment for retaining _actionSpawn --- extensions/CocoStudio/Action/CCActionNode.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/CocoStudio/Action/CCActionNode.cpp b/extensions/CocoStudio/Action/CCActionNode.cpp index 3972d5bfb0..78cf0d3265 100644 --- a/extensions/CocoStudio/Action/CCActionNode.cpp +++ b/extensions/CocoStudio/Action/CCActionNode.cpp @@ -313,7 +313,10 @@ Spawn * ActionNode::refreshActionProperty() } _actionSpawn = Spawn::create(cSpawnArray); - _actionSpawn->retain(); + if (_actionSpawn != NULL) + { + _actionSpawn->retain(); + } return _actionSpawn; } From 082e28b6317d5cb0a7afd26c7c105d089b18a77c Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 23 Sep 2013 14:34:50 +0800 Subject: [PATCH 3/4] fixed action node crash --- extensions/CocoStudio/Action/CCActionNode.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/CocoStudio/Action/CCActionNode.cpp b/extensions/CocoStudio/Action/CCActionNode.cpp index 78cf0d3265..9d7ff8386e 100644 --- a/extensions/CocoStudio/Action/CCActionNode.cpp +++ b/extensions/CocoStudio/Action/CCActionNode.cpp @@ -300,7 +300,10 @@ Spawn * ActionNode::refreshActionProperty() } } Sequence* cSequence = Sequence::create(cSequenceArray); - cSpawnArray->addObject(cSequence); + if (cSequence != NULL) + { + cSpawnArray->addObject(cSequence); + } } if (_action == NULL) From c4dfdbcb14929c5e8b5ffe78c45c9f5ee48637a5 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 23 Sep 2013 14:44:55 +0800 Subject: [PATCH 4/4] change to use CC_SAFE_RELEASE_NULL and CC_SAFE_RETAIN --- extensions/CocoStudio/Action/CCActionNode.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/extensions/CocoStudio/Action/CCActionNode.cpp b/extensions/CocoStudio/Action/CCActionNode.cpp index 9d7ff8386e..31d6e7fe6e 100644 --- a/extensions/CocoStudio/Action/CCActionNode.cpp +++ b/extensions/CocoStudio/Action/CCActionNode.cpp @@ -56,19 +56,18 @@ ActionNode::~ActionNode() { if (_action == NULL) { - CC_SAFE_RELEASE(_actionSpawn); + CC_SAFE_RELEASE_NULL(_actionSpawn); } else { - CC_SAFE_RELEASE(_action); + CC_SAFE_RELEASE_NULL(_action); } if (_frameArray != NULL) { _frameArray->removeAllObjects(); - CC_SAFE_RELEASE(_frameArray); + CC_SAFE_RELEASE_NULL(_frameArray); } - } void ActionNode::initWithDictionary(cs::JsonDictionary *dic,Object* root) @@ -308,18 +307,15 @@ Spawn * ActionNode::refreshActionProperty() if (_action == NULL) { - CC_SAFE_RELEASE(_actionSpawn); + CC_SAFE_RELEASE_NULL(_actionSpawn); } else { - CC_SAFE_RELEASE(_action); + CC_SAFE_RELEASE_NULL(_action); } _actionSpawn = Spawn::create(cSpawnArray); - if (_actionSpawn != NULL) - { - _actionSpawn->retain(); - } + CC_SAFE_RETAIN(_actionSpawn); return _actionSpawn; }