On May 23, 2012, at 05:30 PM, Kevin Perry wrote:

> Does "Revert to Last Saved" become available after saving and editing? Which 
> NSDocument methods are you overriding?

I override:

-autosavesInPlace
-readFromURL:ofType:error:
-writeToURL:ofType:error:
-saveDocument:

plus some others (like -printDocument) which I don't think are relevant.

> 
> It is indeed -updateChangeCount: that controls the 'Edited' state. You might 
> try overriding with a call to super and setting a breakpoint or adding a log 
> to make sure it's being called as expected (with NSChangeDone). That should 
> be getting called by the undo mechanism, but it would be good to verify.

It's being called only once when the document is loaded. It gets called with 
NSChangeCleared, which I guess is what you would expect. I've no idea why it 
isn't called after edits.

If I return NO from autosavesInPlace, I see the same behaviour. The dirty dot 
in the red button does not appear after an edit. If I listen for text did 
change notifications from the text view and call -updateChangeCount in there, 
then everything works normally.

> 
> The only other idea I have is that maybe you need to invoke -[NSTextView 
> breakUndoCoalescing] before saving, like TextEdit does.

I added this, but it doesn't seem to change anything.

Thanks for your thoughts!

Martin


> 
> -KP
> 
> On May 23, 2012, at 8:18 AM, Martin Hewitson <martin.hewit...@aei.mpg.de> 
> wrote:
> 
>> Dear list,
>> 
>> I have an NSDocument app that implements autosave and versions on Lion. The 
>> NSDocument subclass is essentially a text editor. If I create a new document 
>> and type something in the text view then the 'Edited' tag appears. I then 
>> save the document to disk. After this, typing in the text view no longer 
>> triggers the 'Edited' state and hence no versions are autosaved. However, 
>> using "Save a Version" works fine, and I can view the versions in the 
>> versions browser.
>> 
>> Does anyone have a clue what I'm missing? As I understand it, if I'm using 
>> the default NSDocument undo mechanism (which I believe I am - at least 
>> undo/redo works on the editor) then I don't need to manually call 
>> -updateChangeCount:.
>> 
>> What else could I be doing wrong?
>> 
>> Many thanks for any suggestions,
>> 
>> Martin_______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
>> 
>> This email sent to kpe...@apple.com
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to