Re: NSAppleScript crash on executeAndReturnError
Re: NSAppleScript crash on executeAndReturnError
- Subject: Re: NSAppleScript crash on executeAndReturnError
- From: "James J. Merkel" <email@hidden>
- Date: Sun, 28 Nov 2004 18:36:41 -0800
On Nov 28, 2004, at 5:22 PM, Charles Srstka wrote:
On Nov 28, 2004, at 6:51 PM, James J. Merkel wrote:
On Nov 28, 2004, at 1:51 PM, Charles Srstka wrote:
On which line is it crashing?
It crashes on:
finderComment = [[theScript executeAndReturnError: &theError]
stringValue];
That can't be, since if it were crashing here, it wouldn't be getting
far enough to run your NSLog displaying the error message.
No matter, I just tried it with the code sample you posted, and it was
crashing while popping the autorelease pool. After a little
experimentation, I've found that the problem seems to be stemming from
this line:
[theError release];
The reason is that -[NSAppleScript executeAndReturnError:(NSDictionary
**)theError] returns an autoreleased dictionary in the theError
variable. So, get rid of that release statement, and also change this
line:
NSDictionary *theError = [[NSDictionary alloc] init];
to this:
NSDictionary *theError = nil;
to avoid a memory leak.
Opps, my bad. You are correct, the allocate and release of the
NSDictionary are not needed.
When those are removed, the code works reliably.
Thanks for your help.
Jim Merkel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden