From ee1afbb8aa99e10f1dae11d8418e40351f685b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 13 Jan 2015 10:49:07 +0100 Subject: tst_qstring_mac: Correct memory management. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NSStrings return by QString::toNSString are autoreleased; manually releasing them is not correct. The test still works (no leaks or double deletes) since there is no autorelease pool in place when running it. We don't want to encourage incorrect usage: remove the release call an add an autorelease pool. Change-Id: Ic566fd3a8efd6cbc0eb6db850248a68bfc8fed0b Reviewed-by: Timur Pocheptsov Reviewed-by: Gabriel de Dietrich Reviewed-by: Tor Arne Vestbø Reviewed-by: Jake Petroules --- tests/auto/corelib/tools/qstring/tst_qstring_mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm index 9061b6c39d..4cec5b3798 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm +++ b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm @@ -63,17 +63,23 @@ void tst_QString_macTypes() } // QString <-> NSString { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QCOMPARE(QString::fromNSString(nsString), qtString); - [nsString release]; + + [pool release]; } { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QString qtStringCopy(qtString); qtString = qtString.toUpper(); // modify QCOMPARE(QString::fromNSString(nsString), qtStringCopy); - [nsString release]; + + [pool release]; } } -- cgit v1.2.3