DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

Application crash by CCTouchDispatcher on cocos2d v2.0 #1410

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create CCMenuItem with block
2. Inside block set the buttons' parent (menu) to isTouchEnabled = NO;
3. Crash trying to set menu isTouchEnabled = YES;

What is the expected output? What do you see instead?
*** Assertion failure in -[CCTouchDispatcher forceAddHandler:array:], 
.../cocos2d/Platforms/iOS/CCTouchDispatcher.m:88
*** Terminating app due to uncaught exception 
'NSInternalInconsistencyException', reason: 'Delegate already added to touch 
dispatcher.'

What cocos2d version are you using ?
cocos2d v2.0 release

What iOS / Mac SDK are you using ?
4.3 ~ 5.0

Debug or Release ?
All

Which target device / target OS are you using ?
iPhone 5.0

iOS only: Does this happens on device ? or on the simulator ? or on both ?
Both

Mac only: x86 or i386 ?

Please provide any additional information below.
cocos2d 1.0.1 has the same issue #1279 
http://code.google.com/p/cocos2d-iphone/issues/detail?id=1279
but got fix on ver 1.1beta2 thanks to Samuel J. Grabski
fix commit 
https://github.com/cocos2d/cocos2d-iphone/commit/9d0f95e982234398597d3debc229ade
f8d1cda68#commitcomment-1760931

I tried to apply changes on that commit to v2.0, but the API has changed a lot.
Unfortunately, the bug is the same.

Sample Code:
_menuItem=[CCMenuItemSprite itemWithNormalSprite:sprite
                                  selectedSprite:sprite
                                           block:^(id sender)
 {
  _menu=(CCMenu*)((CCMenuItem*)sender).parent;
  _menu.isTouchEnabled=NO;

  _menu.isTouchEnabled=YES;  <--- crash
 }];

Original issue reported on code.google.com by Garf...@gmail.com on 24 Aug 2012 at 12:10

GoogleCodeExporter commented 9 years ago
Interesting... It works on Mac but not on iOS... I guess the event dispatcher 
of mac is more robust.

Original comment by ricardoq...@gmail.com on 26 Sep 2012 at 7:30

GoogleCodeExporter commented 9 years ago
fixed in v2.x
https://github.com/cocos2d/cocos2d-iphone/commit/566366630aeae5be7d4d85f2537cabd
bc8e188e8

Original comment by ricardoq...@gmail.com on 26 Sep 2012 at 9:55

GoogleCodeExporter commented 9 years ago
Thank you Ricardo!

Original comment by Garf...@gmail.com on 27 Sep 2012 at 12:42