summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@digia.com>2012-12-13 14:53:46 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-09 13:09:42 +0100
commit4d670c5747618e056f22da5fc03e51fc01d5ad12 (patch)
tree0c152762eeb571a91d7453478d432ab8a2b654c6 /src/plugins/platforms/cocoa
parentbbb9abf7fb6ceb2c484c08b482a4e9144291d645 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm12
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm7
4 files changed, 16 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index e643f22793..0587da706a 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -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; }
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
index fce72da98f..eb810522d7 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
@@ -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
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index d5841c1983..7c9ae963f6 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -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];
}
diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
index da714d3326..9b94abf115 100644
--- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
@@ -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];
}