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: Philip Dow <email@hidden>
- Date: Wed, 12 Jul 2006 02:11:36 +0200
Oh man, Douglas Davidson, you're gonna be at the Developer's
Conference, right? 'Cause I'm gonna give you a bug hug or something.
Option c is brilliant.
Some quick clarifications for others that I missed on the first run:
Make sure you're subclassing *NSTextBlock* and call [MySubclassPoser
poseAsClass:[NSTextBlock class]] somewhere early on in your
application's initialization.
A massive, huge thanks.
-Phil
On Jul 10, 2006, at 10:40 PM, Douglas Davidson wrote:
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