Mac: Use QString::toNSString in QtBase.

The string is now autoreleased.

This fixes a memory leak in qt_mac_QStringListToNSMutableArrayVoid

Task-number: QTBUG-20347
Change-Id: I11ebeb264af4c8ce98968f2221eea772f24c12d4
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
bb10
Morten Johan Sørvig 2014-03-21 13:48:18 +01:00 committed by The Qt Project
parent d6202762c1
commit 66178447e9
3 changed files with 3 additions and 4 deletions

View File

@ -478,7 +478,7 @@ bool QFseventsFileSystemWatcherEngine::startStream()
NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchedPaths.size()];
for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i)
[pathsToWatch addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(i.key()))];
[pathsToWatch addObject:i.key().toNSString()];
struct FSEventStreamContext callBackInfo = {
0,

View File

@ -74,7 +74,7 @@ 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]))];
[result addObject:list[i].toNSString()];
}
return result;
}

View File

@ -115,14 +115,13 @@ QT_END_NAMESPACE
showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
// Get the names in the nib to match the app name set by Qt.
const NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qt_mac_applicationName()));
const NSString *appName = qt_mac_applicationName().toNSString();
[quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
withString:const_cast<NSString *>(appName)]];
[hideItem setTitle:[[hideItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
withString:const_cast<NSString *>(appName)]];
[aboutItem setTitle:[[aboutItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
withString:const_cast<NSString *>(appName)]];
[appName release];
// Disable the items that don't do anything. If someone associates a QAction with them
// They should get synced back in.
[preferencesItem setEnabled:NO];