CCMessageBox / UIAlertView troubles in cocos2d-2.1rc0-x-2.1.2

Our team just completed migration from cocos2d-x v1 to cocos 2d-x v2. But today I found that my cocos2d-x application crashes with EXC_BAD_ACCESS in random code lines (e.g. in CCTouchDispatcher and so on) when I call CCMessageBox(“putin”, “estdetei”):

  • on iPod 4 with IOS 4.3.5
  • on iPhone 4S with iOS 5.1

On iPad 6.0.1 and iPod 5 with iOS 6.0.1 CCMessageBox works fine.

I use CCMessageBox to inform user about successful purchase, iCloud synchronization and insufficient funds when user tries to buy cheap item. Crash happens when I’m trying to show CCMessageBox near to CCLayer remove code lines (before or after),

Now our app based on cocos2d-2.1rc0-x-2.1.2 . Before migration in cocos 2dx v1 CCMessageBox worked fine in this project.

Also I tried to write my own method to show message (metho in AppController.mm with C++ wrapper):
- showMessage: message title: title
{
NSString
m = "Putins syel vsex detei"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:“Warning” message:m delegate:self cancelButtonTitle:"Cancel" otherButtonTitles:“OK”,nil];
[alert show];
[alert release];
}
*
And it crashes as CCMessageBox :frowning:

Is it known issue? Cocos2d-x guys, do you have new way to show messages to user in cocos 2dx v2 :)?


Screen Shot 2013-04-13 at 3.43.06 PM.png (397.0 KB)

I’m using CCMessageBox in v.2.1 and there were no crashes/problems so far.

Btw, are you sure you should call [alert release] in your showMessage method?

I don’t get it?!

On iOS CCMessageBox is just a CCLog

i don’t know, but I think do you have a zombie object in your ‘touches’ list. from your shot, the ‘this’ pointer is 0x00000000 so is a dead object.

Stefano

Herman Jakobi wrote:

I don’t get it?!
>
On iOS CCMessageBox is just a CCLog

Try GCD.

NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;
NSString * msg = (pszMsg) ? [NSString stringWithUTF8String : pszMsg] : nil;

dispatch_async(dispatch_get_main_queue(), ^{
[UIAlertView alertViewWithTitle:title message:msg cancelButtonTitle:@“OK”];
// or other UIAlertView
});

Dispatch queue make UIAlertView’s emerging function be called one time later, so it prevent from calling EAGLView touchesEnded:withEvent.
It works for me.