More explicit QCocoaAccessibleElement memory mngmt
Don't autorelease in the elementWithInterface function, rename it to createElementWithInterface. The element can then be released immediately or autoreleased ("delete later"). Change-Id: I155a85404c34d756c1752eb7c24a7fb0f3cf2e77 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
parent
bbb9abf7fb
commit
4d670c5747
@ -71,7 +71,8 @@ void QCococaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
|
||||
case QAccessible::TextInserted :
|
||||
case QAccessible::TextRemoved :
|
||||
case QAccessible::TextUpdated : {
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement elementWithInterface : interface parent : nil];
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithInterface : interface parent : nil];
|
||||
[element autorelease];
|
||||
NSAccessibilityPostNotification(element, NSAccessibilityValueChangedNotification);
|
||||
break; }
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
}
|
||||
|
||||
- (id)initWithInterface:(void *)anQAccessibleInterface parent:(id)aParent;
|
||||
+ (QCocoaAccessibleElement *)elementWithInterface:(void *)anQAccessibleInterface parent:(id)aParent;
|
||||
+ (QCocoaAccessibleElement *)createElementWithInterface:(void *)anQAccessibleInterface parent:(id)aParent;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -68,9 +68,9 @@ static QAccessibleInterface *acast(void *ptr)
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (QCocoaAccessibleElement *)elementWithInterface:(void *)anQAccessibleInterface parent:(id)aParent
|
||||
+ (QCocoaAccessibleElement *)createElementWithInterface:(void *)anQAccessibleInterface parent:(id)aParent
|
||||
{
|
||||
return [[[self alloc] initWithInterface:anQAccessibleInterface parent:aParent] autorelease];
|
||||
return [[self alloc] initWithInterface:anQAccessibleInterface parent:aParent];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
@ -136,7 +136,9 @@ static QAccessibleInterface *acast(void *ptr)
|
||||
NSMutableArray *kids = [NSMutableArray arrayWithCapacity:numKids];
|
||||
for (int i = 0; i < numKids; ++i) {
|
||||
QAccessibleInterface *childInterface = acast(accessibleInterface)->child(i);
|
||||
[kids addObject:[QCocoaAccessibleElement elementWithInterface:(void*)childInterface parent:self]];
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithInterface:(void*)childInterface parent:self];
|
||||
[kids addObject: element];
|
||||
[element release];
|
||||
}
|
||||
|
||||
return kids;
|
||||
@ -251,7 +253,9 @@ static QAccessibleInterface *acast(void *ptr)
|
||||
}
|
||||
|
||||
// hit a child, forward to child accessible interface.
|
||||
QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithInterface:childInterface parent:self];
|
||||
QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement createElementWithInterface:childInterface parent:self];
|
||||
[accessibleElement autorelease];
|
||||
|
||||
return [accessibleElement accessibilityHitTest:point];
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,9 @@
|
||||
int numKids = m_accessibleRoot->childCount();
|
||||
NSMutableArray *kids = [NSMutableArray arrayWithCapacity:numKids];
|
||||
for (int i = 0; i < numKids; ++i) {
|
||||
[kids addObject:[QCocoaAccessibleElement elementWithInterface: m_accessibleRoot->child(i) parent:self ]];
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithInterface: m_accessibleRoot->child(i) parent:self ];
|
||||
[kids addObject: element];
|
||||
[element release];
|
||||
}
|
||||
|
||||
return kids;
|
||||
@ -98,7 +100,8 @@
|
||||
|
||||
// Hit a child, forward to child accessible interface.
|
||||
|
||||
QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithInterface: childInterface parent:self ];
|
||||
QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement createElementWithInterface: childInterface parent:self ];
|
||||
[accessibleElement autorelease];
|
||||
return [accessibleElement accessibilityHitTest:point];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user