[Interest] [OT] Re: autosave on OSX
Raul Metsma
raul at innovaatik.ee
Thu Oct 25 10:08:34 CEST 2012
Here is overview
http://developer.apple.com/library/mac/#documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html
Raul
On Oct 25, 2012, at 11:02 AM, Till Oliver Knoll <till.oliver.knoll at gmail.com> wrote:
> 2012/10/25 Lincoln Ramsay <a1291762 at gmail.com>:
>> ...
>> If you want "Mac" document handling (including Lion autosave/versions), you
>> need to use NSDocument.
>
> Absolutely correct.
>
> To my surprise it was unexpectedly hard to find any useful information
> about that matter, e.g. a google search "lion autosave tutorial" shows
> mostly desperate forum entry how to /disable/ that feature ;)
>
> But from what I gather from the Apple docs about NSDocument itself I
> think given an instance of NSDocument:
>
> https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html
>
> * Let the system know that you support auto-save: autosavesDrafts
>
> * Let the system know that you support "in place" autosave: autosavesInPlace
>
> I *think* the later, when returning YES, will tell the system that it
> is fine to do "auto-saving" and replacing the original file path (if
> the file was ever stored manually with "Save As" - otherwise the file
> is stored at a temporary location).
>
> Then the flag NSSaveOperationType will tell you what kind of auto-save
> operation is going on (in the appropriate "save document" methods).
> Notice the two newly added values (OS X 10.7)
> NSAutosaveElsewhereOperation ("document has never been saved manually
> by the user: no file path") and NSAutosaveInPlaceOperation ("overwrite
> the existing file").
>
> To support "Versions" you would have at least to return YES in
> "preservesVersions" (and possibly support/implement other methods),
> and most likely you also want to implement "duplicateDocument" etc.
>
> At least that's what I understand so far.
>
>
> "How to call Objective-C APIs from within C++" in a nutshell:
>
> * Mix C++ and Objective-C code in Objective-C++ source files: *.mm
> * You can instantiate a C++ class from within Objective-C classes,
> even keep references to them and vice versa
> * You can pass plain simple C types such as int, float, double from
> C++ to Objective-C methods (and vice versa) without problems etc.
> * But you should never go as far as inheriting an Objective-C class
> from a C++ base class or vice versa ;)
> * (More restrictions probably apply, but that's what I remember out of my head)
> * Finally, add those Objective-C++ sources to your qmake project:
>
> mac {
> OBJECTIVE_SOURCES += YourClass.mm
> }
>
> * Link with the appropriate Cocoa frameworks explicitly, if needed
>
>
> Lastly, you should consider whether that "Lion auto-save" is really
> such a great feature (or whether you don't want at least to provide an
> option to revert to the classic "Save/Save As" approach):
>
> "That bloody autosaving is a disaster for me. I can not work with it.
> Duplicates, duplicates and duplicates all over, when needing to save
> the same picture in different formats. I can't keep track of it and it
> makes a huge mess which steals time. If I make a mistake my original
> Jpegs gets destroyed, without any warnings."
>
> [http://support.pixelmator.com/viewtopic.php?f=4&t=7137]
>
>
> Yes, Apple re-introduced a "kind-of Save As" operation again in
> Mountain Lion 10.8 (learing from above "disasters" ;)). But from what
> I know last is that it *still* also saves the original document at the
> same time, too! Ouch! Hence "kind of" Save As ;)
>
>
> I agree that for a certain user group this Auto Save might be a good idea.
>
> But my own experience is that I never ever lost a document due to a
> "power outtage" or any other of those "You should have saved" moments
> that Phil Schiller was telling us about when they introduced that
> feature (yes, I did loose documents due to application crashes! But
> I'd rather not have such an app auto-save my document at the very
> moment it crashes - and if it does, please don't overwrite the actual
> file ;)).
>
> But I lost more nerves when I mindlessly started to change video edits
> in Final Cut Pro X, just to experiment a bit - simply to realise
> moments later that -shit!- I just modified that movie which was
> already good as it was! So keep pressing Undo, Undo, Undo,... (even
> though I am not even sure whether FCP X is actually using that
> "Autosave" feature: I think it is more of a Core Data application
> which more or less immediatelly reflects all your model changes in the
> underlying DB or XML files).
>
> Or Preview: each time I double-click e.g. a PDF first dozens of other
> documents I had previewed at some previous time are opened first
> (auto-save goes hand-in-hand with that "application restauration
> thing"), possibly even in full-screen mode. And I got the feeling that
> each time I get presented another document - not the one I
> double-clicked on! - in fullscreen mode! So close, close, close all
> those rubbish previews first and search my actual preview document.
>
> Even worse with the QuickTime player: want to see a movie? You have to
> fight through all the previous movies you did not close previously!
>
> I know, I know, there's some *.plist configuration entry how you can
> disable this "auto-restauration" feature. But so far Text Edit,
> Preview and QuickTime are the only applications I use from Apple
> (besides FCP X) and I have learnt to ignore and suffer ;) All other
> applications still have the good ol' Save As functionality (for now
> ;))
>
> Just my 0.02$
>
> Cheers, Oliver
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list