Re: DO crashes when returning NSError by reference
Re: DO crashes when returning NSError by reference
- Subject: Re: DO crashes when returning NSError by reference
- From: Charles Srstka <email@hidden>
- Date: Sun, 8 Apr 2007 13:12:06 -0500
On Apr 8, 2007, at 9:05 AM, Scotty's Lists wrote:
Charles,
Sorry, I looked closer at the DRMAASession.m file ref I sent you
and it's not the most recent rev in the respository.
This link gives you the most recent (and seemingly fully
implemented) version of the class.
<http://code.edbaskerville.com/websvn/filedetails.php?
repname=XgridDRMAA&path=/trunk/framework/objc%
2FXgridDRMAASession.m&sc=1>
Thanks. I think I've figured out what the problem was. My initial
simplification of my code from my original snippet was not entirely
accurate. What was actually going on was more like this:
- (BOOL)foo:(NSError **)error
{
// do a bunch of stuff
BOOL success = [helper bar:error];
// do a bunch more stuff
}
The problem was that foo: was sometimes getting called with nil for
the "error" parameter, when the caller didn't care about the error
message. This got passed on to bar:, which crashed. Apparently, with
DO you can't pass NULL for values you don't want that are returned by
reference.
This fixed it:
- (BOOL)foo:(NSError **)error
{
// do a bunch of stuff
NSError *theError = nil;
BOOL success = [helper bar:&theError];
if(error) *error = theError;
// do a bunch more stuff
}
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden