Skip navigation.
 
mlRe: Tables in TextView malformed after archiving and unarchiving
FROM : Douglas Davidson
DATE : Mon Jul 10 22:40:14 2006

For all those who have asked about this issue:  sorry I haven't 
replied sooner (I've been sick :).

This is a known bug in NSTextBlock keyed unarchiving.  We have a fix 
internally.

Here are some possible workarounds:  (a) used non-keyed archiving; 
(b) archive some additional data along with the blocks (e.g., add an 
attribute whose value is an NSData, obtained by non-keyed archiving 
the block) and use it to fix them up afterwards; (c) implement 
something like the code shown below in a posing subclass (this should 
be safe even after our fix makes it out).

Douglas Davidson


static NSLock *unarchivingTextBlockLock = nil;
static CFMutableSetRef unarchivingTextBlockSet = NULL;

- (id)initWithCoder:(NSCoder *)coder {
    if (!unarchivingTextBlockLock) unarchivingTextBlockLock = 
[[NSLock alloc] init];
    [unarchivingTextBlockLock lock];
    if (!unarchivingTextBlockSet) unarchivingTextBlockSet = 
CFSetCreateMutable(NULL, 0, NULL);
    CFSetAddValue(unarchivingTextBlockSet, (const void *)self);
    [unarchivingTextBlockLock unlock];
    self = [super initWithCoder:coder];
    [unarchivingTextBlockLock lock];
    CFSetRemoveValue(unarchivingTextBlockSet, (const void *)self);
    [unarchivingTextBlockLock unlock];
    return self;
}

- (void)_createFloatStorage {
    BOOL create = YES;
    if (_propVals) {
        [unarchivingTextBlockLock lock];
        if (unarchivingTextBlockSet && CFSetContainsValue
(unarchivingTextBlockSet, (const void *)self)) create = NO;
        [unarchivingTextBlockLock unlock];
    }
    if (create) [super _createFloatStorage];
}

Related mailsAuthorDate
mlTables in TextView malformed after archiving and unarchiving Philip Dow Jul 6, 14:25
mlRE: Tables in TextView malformed after archiving and unarchiving Keith Blount Jul 7, 17:42
mlRe: Tables in TextView malformed after archiving and unarchiving Philip Dow Jul 8, 00:09
mlRe: Tables in TextView malformed after archiving and unarchiving Douglas Davidson Jul 10, 22:40
mlRe: Tables in TextView malformed after archiving and unarchiving Philip Dow Jul 12, 02:11
mlRe: Tables in TextView malformed after archiving and unarchiving Douglas Davidson Jul 12, 02:18