Quoting MenTaLguY <mental@...3...>:
However, should we count SPDesktops, or more generally all SPViews (for example the preview view)?
Is SPDocument necessarily the place to actually keep track of that, or should it be e.g. the Inkscape Application object?
Nope.
SPDocument is not really the place to keep track of that. It's a model view. It should know that it is dirty, but that's it. All traces of UI awareness should be kept out of it.
Instead, perhaps the ViewManager should track it.
We were hammering out the other day that we'd want something like a ViewSet to hold a set of Views on a given document. The set would keep one or more views together, like for split-pane views. Though there'd be one document per ViewSet, we could have multiple ViewSets per document (split-pane view in one Window, and a zoomed-out 100% view in a separate window).
The ViewManager could track and notice when the last ViewSet capable of 'owning' a document save was closed.
Or... if we don't toss in a ViewManager, then the UIApplication could track it. And at first perhaps we won't have ViewSet, but it would be good to work towards it.
Hmmm.... then there's the case of command-line invocation and such. Maybe we'd want some abstract interface like 'DocumentHolder' that may be a UI ViewSet or may be just an internal non-UI thing.