Re: Tables in TextView malformed after archiving and unarchiving
Re: Tables in TextView malformed after archiving and unarchiving
- Subject: Re: Tables in TextView malformed after archiving and unarchiving
- From: Douglas Davidson <email@hidden>
- Date: Mon, 10 Jul 2006 13:40:14 -0700
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];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden