Applescript commands sent immediately after iPhoto launch often fail
| Originator: | bewebste | ||
| Number: | rdar://10280413 | Date Originated: | 13-Oct-2011 10:31 AM |
| Status: | Closed | Resolved: | |
| Product: | iLife | Product Version: | iPhoto 9.2 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
If an Apple event is sent to iPhoto immediately after it launches, that event will often result in an error.
Steps to Reproduce:
Copy and paste the following Applescript into Applescript Editor, and click "Run"
--quit iPhoto if it's alreeady running
tell application "System Events"
if exists application process "iPhoto" then
tell application "iPhoto" to quit
repeat while exists application process "iPhoto"
delay 1
end repeat
end if
end tell
tell application "iPhoto"
set success to false
repeat while not success
try
--This command will trigger the launching of iPhoto
--With iPhoto 9.2, this almost always results in an error
set albumName to name of first album
display dialog "Success, first album name is " & albumName
set success to true
on error errorMessage number errorNumber
--Catch the error, then retry. The second time around, the command always works
display dialog "Got an error back (" & errorMessage & ", " & errorNumber & ")" buttons {"Retry", "Cancel"} default button "Retry"
end try
end repeat
end tell
Expected Results:
The script should display only the success dialog, displaying the name of the first album in the library
Actual Results:
Instead, the first attempt to fetch the album name fails with a -10000 error. Additionally, the following is output to the console log:
10/13/11 8:36:28.963 AM iPhoto: An exception was thrown during execution of an NSScriptCommand...
10/13/11 8:36:28.964 AM iPhoto: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
If you click "Retry", the second attempt to fetch the album name always succeeds.
Regression:
This problem is new with iPhoto 9.2, and does not occur with previous versions.
Some Applescript commands will not fail in this manner, but most will. It appears that basically anything that needs to access to the data objects of iPhoto (albums, photos, etc.) will encounter a similar problem. This includes any get/set commands on iPhoto objects, as well as things like the "new album" command.
On very rare occasion, this script will not encounter an error. I believe the problem has something to do with the timing of the library loading, so every once in a while iPhoto will load fast enough to be able to handle the Apple event correctly.
Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!