I've got an AppleScript, which is triggered by a beforeSave event listener. This script makes some modifications to the active document, and then the save proceeds. The problem I'm encountering is that, after the save, the document appears as saved momentarily, but then immediately reverts back to unsaved. This is evident by an asterisk disappearing and reappearing next to the document name in the document window's title bar. If I comment out the document modification code, the save works as expected.
It seems like maybe the save is continuing while the script is still in progress, and this is why the document reverts to unsaved. However, shouldn't the beforeSave event take place before the save occurs, and not proceed until the script has finished executing?
Things I've checked and/or tried…
* I've checked to see if somehow my script is being triggered a second time after the save is complete. It is not.
* I've tried having my script save the document on completion, but this fails because the database is busy.
* I've tested with beforeSaveAs, and it encounters the same problem.
* I've tested on multiple machines. What's weird is that it occurs on some, and not on others. So, it's not consistent.
* I have seen the problem in Mac OS X 10.5.x and 10.6.x. I have not tested it in 10.7.x yet.
* I have seen the problem with CS5, but have not yet encountered it with 5.5.
Anyone have any thoughts or suggestions?