On 07/10/2009, at 3:37 PM, Kyle Sluder wrote:

I can't imagine the
usefulness of replacing the contents of the text storage instead of
just swapping in the new one.


I do this because previously I was replacing the text storage and that was causing a huge amount of upset for Undo, producing a crash deep inside the undo manager for a private object it maintains. (Essentially, the target for a text editing undo operation is the text storage, so if it's replaced the reference is stale, since Undo tasks do not retain their targets). In fact I recall that it was you who suggested that using -replaceTextStorage: would cause problems for Undo and suggested replacing the content instead. Indeed, that did seem to eradicate that particular source of problems. I didn't try it but -setTextStorage: would presumably have the same effect on Undo, making it unsafe.

However, there were other problems anyway so I ended up disabling Undo for typing when the text is being edited. I'd like to be able to re- enable it at some point but I can't see a very nice way to consolidate the two "phases" for Undo - typing, then just getting the typed text and setting it back into my data model, which is also undoable. At that point the undos relating to typing should be removed from the undo stack but I can't find a stable way to do that, hence disabling Undo for typing altogether.

http://www.cocoabuilder.com/archive/message/cocoa/2009/9/16/245160

--Graham
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to