Editor: Handle document closing
When the user is trying to close the last view of a document, do the following:
- If the document is not saved, warn the user and give him an option to save.
- If there are still operations running on this document, warn the user and give him the option to either wait or abort the operations (plus canceling closing the document).
Note: Operations (including save) are potentially asynchronous. You can not expect them to finish after returning from the respective function (e.g. save) nor can you expect them to abort immediately on calling abort. Instead you should wait for the state change, which is broadcasted through the updateDocumentState function of the View class.