Author: ericwa Date: Tue Mar 18 19:08:39 2014 New Revision: 10582 URL: http://svn.gna.org/viewcvs/etoile?rev=10582&view=rev Log: Typewriter: hack to avoid an exception on the first edit in a new note
Modified: trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m Modified: trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m URL: http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m?rev=10582&r1=10581&r2=10582&view=diff ============================================================================== --- trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m (original) +++ trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m Tue Mar 18 19:08:39 2014 @@ -15,6 +15,7 @@ #import "PrioritySplitViewDelegate.h" #import "EWHistoryWindowController.h" #import <CoreObject/COAttributedStringDiff.h> +#import <CoreObject/COObject+Private.h> @implementation EWTypewriterWindowController @@ -540,6 +541,17 @@ TypewriterDocument *oldDoc = [[selectedNote objectGraphContextForPreviewingRevision: [selectedNote currentRevision]] rootObject]; COAttributedString *oldAs = oldDoc.attrString; + // HACK: -[COAttributedStringDiff initWithFirstAttributedString:secondAttributedString:source:] will throw an exception + // if the first attributed string is nil, which can happen for a new document. Just make an empty string in that case. + COObjectGraphContext *tempCtx = [COObjectGraphContext new]; + if (oldAs == nil) + { + oldAs = [[COAttributedString alloc] prepareWithUUID: as.UUID + entityDescription: [[selectedNote.editingContext modelDescriptionRepository] entityDescriptionForClass: [COAttributedString class]] + objectGraphContext: tempCtx + isNew: YES]; + } + COAttributedStringDiff *diff = [[COAttributedStringDiff alloc] initWithFirstAttributedString: oldAs secondAttributedString: as source: nil]; _______________________________________________ Etoile-cvs mailing list Etoile-cvs@gna.org https://mail.gna.org/listinfo/etoile-cvs