• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSAppleScript crash on executeAndReturnError
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSAppleScript crash on executeAndReturnError (From: "James J. Merkel" <email@hidden>)
 >Re: NSAppleScript crash on executeAndReturnError (From: Nick Zitzmann <email@hidden>)
 >Re: NSAppleScript crash on executeAndReturnError (From: "James J. Merkel" <email@hidden>)
 >Re: NSAppleScript crash on executeAndReturnError (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Checking for line ending types
  • Next by Date: Re: How do I get around this?
  • Previous by thread: Re: NSAppleScript crash on executeAndReturnError
  • Next by thread: Resizing an image inside a text view
  • Index(es):
    • Date
    • Thread