Might the document's size be an issue? They tend to be over 100 Mb. It's certainly not ALL the documents that I open: only a few.
Possibly. The data object you're handed was created by passing NSDataReadingMappedIfSafe into the NSData initializer, which means you do have a certain connection to the file system. However, the bigger issue is whether or not you have unsaved changes.
It's worth saying that I've deliberately switched off the auto-save functionality (autosavesInPlace = false).
Can I ask what you mean by "checking the documentEdited property“?
NSDocument.documentEdited is the property which notes whether or not the document has been modified, which would generally indicate there are unsaved changes.
Among other properties, it's actually what triggers this alert:
If I close a document with unsaved changes, it flags an alert saying that there are unsaved changes; do you want to save them? If there aren't, then the document closes gracefully.
I'll see if I can trigger it again and investigate a bit.
Again, the big question here is whether the problem happens AFTER you've closed all of your documents. If it does, then that implies that you’re leaking some kind of file reference.
Oh - one other possible factor: the files are locked in the Finder, to prevent edits.
That's actually a bit of a surprise, as that should end up short-circuiting most of the kinds of checks I'd expect. Is NSDocument.inViewingMode getting set? If so, is the file also marked as having unsaved changes? I think NSDocument can be configured to allow "modification" of locked files, as that's a common way to start new documents from a "template". The file lock prevents saving the file at the existing location, but it doesn't stop you from saving the modified variation to a new location.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware