Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
4.7.3
-
None
-
Mac OS X 10.6.8
-
66178447e91f56eaeaee203171b9355399d3bb5c
Description
NSString not released after it is added to the NSMutableArray.
The code we have in qt_cocoa_helpers_mac.mm
void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list) { NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.size()]; for (int i=0; i<list.size(); ++i){ [result addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(list[i]))]; //Here is a leak! } return result; }
It should use another function from the helper to do the QString -> NSString conversion:
void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list) { NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.size()]; for (int i=0; i<list.size(); ++i){ [result addObject:qt_mac_QStringToNSString(list[i])]; //Now leak is gone!(If the autorelease pool is used, but I think it is) } return result; }
the same is applicable for -(void)registerDragTypes in qcocoasharedwindowmethods_mac_p.h and maybe for other places which I didn't find.
P.S. Leak was found with Instruments tool.