It's just a standard NSOpenPanel I'm not subclassing, nothing special that I can think of.
More code:
NSString *currentDoc=nil;
BOOL ok=1;
if(currentDoc==nil) {
//create new file
int result;
NSArray *fileTypes = [NSArray arrayWithObject:@"mbp"];
NSSavePanel *oPanel = [NSSavePanel savePanel];
[oPanel setAllowedFileTypes:fileTypes];
result = [oPanel runModal];
if (result == NSOKButton) {
NSString *fileName = [[[oPanel URL] path] retain];
currentDoc = fileName;
}
else
ok=0;
}
if(ok) {
.
.
. etc
Basically just running the panel and waiting for a result, either a filename or a cancel to the load.
The crashes always happen in AppKit libraries and not cocos2d, googling around I found a few people having issues with running modal panels and would get crashes when running from different threads, but that's as much as I understood of it.
A common error I get:
<Error>: kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region
<Error>: kCGErrorIllegalArgument: CGSGetRegionBounds : Invalid region
This doesn't generate a crash, but for example this did:
*** Assertion failure in -[NSTrackableOutlineView _expandItemEntry:expandChildren:startLevel:], /SourceCache/AppKit/AppKit-1038.35/TableView.subproj/NSOutlineView.m:969
<NSNavFBENode: 0x1003e7f70>: 'Places': isAlias(NO) _fbeNode:0x1003d5800 should not be expanded already!
Other random crashes like this one, all to do with some internal method of the Panel.
Any ideas?