4

Every so often, I will be doing something on my computer (e.g., in Google Chrome), when an alert dialog from TextEdit.app randomly pops up. The dialog looks like this:

The dialog asks if I want to save changes made to an open or minimized RTF document in TextEdit. The dialog sometimes appears even when TextEdit is not the active application; the dialog comes out of nowhere.

My answer to this dialog, 100% of the time, is Save Anyway. This is because hitting the Revert button irrevocably changes the file to the last-saved version of the file (which is obviously undesirable).

  1. If the document is not being edited in another application, then why does this message appear? Or, how can I figure out which application (i.e., "another application") is responsible for the changes to the document, exactly?

  2. Is it possible to prevent this dialog from needlessly appearing? Or, is it possible for Textedit to "save anyway," by default?

OS X El Capitan, version 10.11.6.

2

I've never seen this sheet without the underlying file being changed. Try opensnoop on the file to determine the process which is accessing the file:

$ sudo opensnoop -f /path/to/file.txt
  UID    PID COMM          FD PATH
  501  32092 Finder        14 /path/to/file.txt
    0     81 mds           28 /path/to/file.txt
  501  41898 mdworker       9 /path/to/file.txt
  501  42646 TextMate      16 /path/to/file.txt
  501  42646 TextMate      16 /path/to/file.txt
  501  42646 TextMate      25 /path/to/file.txt
  501  42646 TextMate      26 /path/to/file.txt

This is a live printout, so keep the opensnoop running until you get the sheet, then check your Terminal window and look back to see the process. ⌃C stops opensnoop when you're finished. You will need to disable System Integrity Protection to use opensnoop and can be re-enabled afterwards.

  • I get the following message in Terminal after entering the opensnoop line: token too large, exceeds YYLMAX. Do you know how to fix this? – rubik's sphere May 25 '17 at 16:27
  • @rubik This is due to incorrect quoting in opensnoop for files with spaces in the path. Open /usr/bin/opensnoop with a text editor and add a pair of double quotes directly around the $ variables on lines 162 and 163. 162 should now read inline string PATHNAME = "'"$pathname"'";, such that each side of quotes went from " ' to " ' " (without spaces). – grg May 25 '17 at 18:31
  • How do you save the edited file? I can't save it in TextEdit or TextWrangler. I am given the error: You don’t own the file “opensnoop” and don’t have permission to write to it. I also tried pasting the edited file in the /usr/bin/ folder, and it wouldn't work. When I try to change the file or folder permissions via the "Get Info" window in Finder, I get the error: The operation can’t be completed because you don’t have the necessary permission. But, my user account is an administrator account and it is the only user. – rubik's sphere May 25 '17 at 20:29
  • @rubik You'll need to disable System Integrity Protection to modify system files. Since you have to disable it to use opensnoop, I forgot to mention that. – grg May 25 '17 at 21:29
  • Do you happen to know what RSScriptRunner and cp refer to? Based on my opensnoop log, I believe that it is one or both of these processes that is responsible for accessing/editing the .rtf file in the background. – rubik's sphere Jun 11 '17 at 7:23
0

Closure:

I followed the instructions provided by user grgarside in their answer.

I realized that the .rtf file was, in fact, being altered by another application. Hence, it is entirely appropriate that I was given the The file has been changed by another application. dialog.

As grgarside suggested, the dialog never actually appeared needlessly.

Specifically, the file was being changed by an AppleScript of mine. The solution was to implement a check in the AppleScript code, to see if the .rtf file was already open. If the .rtf file was open, then I made sure that my AppleScript code would not write text to this file.

After I made the fix to my AppleScript code, I have never seen this dialog again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .