Releasing the document observer will trigger a “document will delete” notification, and I am seeing a few crashes from this. I don’t see any theoretical problem with posting this from the destructor, as the object is still “live”, but let’s see if this change doesn’t fix the crashes.
We have been detecting plug-in crashes for about two years, and we offer the user to remove crashing plug-ins, nonetheless we are still getting a significant number of crash reports from loading the Emmet plug-in.
Previously when multiple windows had unsaved changes we would use the frontmost window (with unsaved changes) for all the dialogs. Now we always bring to front the document for which we are presenting a sheet (like a save panel or encoding error).
Our previous save code was incompatible with the app termination event loop, so we had to abort app termination, but the updated code does not seem to have any issue.
We only run uniqueSpellDocumentTag and closeSpellDocumentWithTag: on the main thread, as the spelling methods themselves should be thread safe and do not cause any tests to fail (even when running them in parallel).
The way we check if we must “jump” to main thread is done by looking at our current run loop rather than using the deprecated (as of 10.9) dispatch_get_current_queue() function. Since we are looking at the run loop, we now use CFRunLoopPerformBlock() instead of the dispatch functions.
While the previous changes were motivated by the tests, this one affects TextMate in that we run a local event loop if we want to wait for commands to finish, but as we previously used the main dispatch queue to send back command results, it meant that we could not wait for command completion from a block running in the main queue.
Currently the code works around this by using performSelector:withObject:afterDelay: when there is a chance of being in a local event loop, which is no longer required.
With this change we only have OakTextView observe its current document.
This does mean that currently pre and post bundle actions are only executed for the selected document.
This will also ensure the display name does not contain any slashes (which it can when a custom name is set) so that it is safe to use this as a filename.
We would only set the “default” project directory and rely on the effective project directory being set when opening first document, however, for untitled documents we need the effective project directory to be setup prior to opening (to read the correct settings).