Re: Handle data disappearing out from underneath me
Re: Handle data disappearing out from underneath me
- Subject: Re: Handle data disappearing out from underneath me
- From: Ken Tozier <email@hidden>
- Date: Sun, 8 Apr 2007 10:48:52 -0400
Here's the Console log printout info
2007-04-08 10:46:47.297 QuarkXPress[7423] in NSObject from handle
data: <403fe923 ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff 802feb23 50630224 a070eb23 5015cc29
80d7eb23 6016cc29 ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff >, length: 236
2007-04-08 10:46:47.297 QuarkXPress[7423] CFLog (0):
CFPropertyListCreateFromXMLData(): plist parse failed; the data is
not proper UTF-8. The file name for this data could be:
/Users/kentozier/Library/KeyBindings/DefaultKeyBinding.dict
The parser will retry as in 10.2, but the problem should be
corrected in the plist.
On Apr 8, 2007, at 10:24 AM, Ken Tozier wrote:
Hi
My plugin converts NSObjects to handles for storage in a parent
application and am finding that the data the handle points to seems
to disappear out from underneath me. When I fetch the handle from
the parent app at a later time, the handle itself isn't null, but
the data it pointed to is.
Here's how I'm packing the NSObjects into a handle:
BOOL UtilSlugHandleFromNSObject(id inSlug, Handle *result)
{
BOOL exeOK = NO;
NSString *err = nil;
NSData *data;
data = [NSPropertyListSerialization dataFromPropertyList: inSlug
format: NSPropertyListXMLFormat_v1_0
errorDescription: &err];
*result = NULL;
if (err == nil)
{
PtrToHand([data bytes], result, [data length]);
exeOK = YES;
}
else
NSLog(@"Error: %@ serializing slug: %@", err, inSlug);
return exeOK;
}
And here's how I'm pulling the NSObjects back out of the handles
id UtilNSObjectFromSlugHandle(Handle inSlugHandle)
{
id result = nil;
if (inSlugHandle != NULL)
{
NSString *err = nil;
HLock(inSlugHandle);
NSData *slugData = [NSData dataWithBytes: inSlugHandle length:
GetHandleSize(inSlugHandle)];
HUnlock(inSlugHandle);
NSLog(@"In: UtilNSObjectFromSlugHandle, slugData: %@, slugData
length: %i", slugData, [slugData length]);
result = [NSPropertyListSerialization
propertyListFromData: slugData
mutabilityOption: NSPropertyListMutableContainersAndLeaves
format: NULL
errorDescription: &err];
if (err != nil)
NSLog(@"Error: %@ while attempting to deserilize slug: %@", err,
slugData);
}
return result;
}
The NSLog for slugData in UtilNSObjectFromSlugHandle above displays
a data chunk that is mostly filled with ff with a valid length.
Being an autoreleased NSData probably has something to do with it
but I would have thought that PtrToHand did something internally to
prevent the deletion of the data it points to. Is there some other
way I can prevent these disappearing handles?
Thanks for any help
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40comcast.net
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden