Re: GC bug in NSFontManager?
Re: GC bug in NSFontManager?
- Subject: Re: GC bug in NSFontManager?
- From: Quincey Morris <email@hidden>
- Date: Tue, 30 Jun 2009 15:20:00 -0700
Well, still tooling around waiting for someone who knows something to
jump in ...
I can think of two easy things you can try, if it's possible to get a
test build to users who are seeing problems.
1. Just before some of the places where the crashes occur, log the
address of the object you're passing to the font manager method. That
way, if it crashes with the "unrecognized selector" exception, you can
tell if the (apparently) collected-away object is yours. However, keep
in mind that logging may just change the multithreading timing so that
the crash coincidentally stops happening, even though the real problem
persists.
2. Add access to your objects to keep them alive until the font
manager is done with them, in case the font manager is for some reason
failing to maintain strong references properly. If that solves it, you
know the "what", just not the "why".
So with both of these in place, the code sample you showed earlier
would look like this:
On Jun 30, 2009, at 11:34, Ross Carter wrote:
- (NSDictionary *)fontNamesFamiliesDictionary {
NSMutableDictionary *returnVal = [NSMutableDictionary dictionary];
NSFontManager *fm = [NSFontManager sharedFontManager];
NSArray *familyNames = [fm availableFontFamilies];
NSString *familyName;
for (familyName in familyNames) {
NSLog (@"familyName: %p", familyName); // 1 above
NSArray *memberDescriptions = [fm
availableMembersOfFontFamily:familyName];
NSArray *memberDescription;
for (memberDescription in memberDescriptions) {
NSLog (@"memberDescription: %p", familyName); // 1 above
NSString *fontName = [memberDescription objectAtIndex:0];
if (fontName != nil) {
[returnVal setObject:familyName forKey:fontName];
}
[memberDescription self]; // 2 above
}
[familyName self]; // 2 above
}
return returnVal;
}
Incidentally, you did check there weren't any related console log
messages just before the crash, didn't you? (Speaking from painful
personal experience.)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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