Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
- Subject: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 11 Nov 2010 08:21:53 -0500
On Nov 11, 2010, at 7:04 AM, Peter Lübke wrote: - (id)valueForAttributeCopy:(CFStringRef)attribute { id value = nil; id axValue = nil; NSArray *attrNames;
if (AXUIElementCopyAttributeNames((CFTypeRef)_element, (CFArrayRef *)&attrNames) == kAXErrorSuccess) { if ( [attrNames indexOfObject:(NSString *)attribute] != NSNotFound && AXUIElementCopyAttributeValue((CFTypeRef)_element, attribute, (CFTypeRef *)&axValue) == kAXErrorSuccess ) value = axValue; } [attrNames release];
return value; }
I believe it's OK to cast a CFTypeRef to a toll-free-bridged NSObject and then 'release' or 'autorelease' it instead of 'CFReleas'ing it.
However, you have neglected to CFRelease (or release, or autorelease) the value stored in axValue by the AXUIElementCopyAttributeValue() function call in the body of your method The Cocoa convention is that a method like your -valueForAttributeCopy: always returns an object autoreleased. So, you might want to add '[axValue autorelease]' or '[value autorelease]' before the return, or change the last line to 'return [value autorelease]', and see what happens. (If the caller of your method does releases its return value when done with it, remove that release because it would be automatically released by the autorelease added in your method). |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden