summaryrefslogtreecommitdiff
path: root/src/video/cocoa
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2019-09-01 15:27:39 +0200
committerMichael Lutz <michi@icosahedron.de>2019-11-01 22:32:53 +0100
commitd5a9bd404a3ca90a18abeeaaaabdbf5185437ba7 (patch)
tree5dc82f54f00bc5633e4131d7c77f988367beb425 /src/video/cocoa
parent58122983fb1284270a4fd9f420b1c3a3a3605bcb (diff)
downloadopenttd-d5a9bd404a3ca90a18abeeaaaabdbf5185437ba7.tar.xz
Codechange: [OSX] Use std::unique_ptr with a custom deleter to simply memory management of Core Foundation types.
Diffstat (limited to 'src/video/cocoa')
-rw-r--r--src/video/cocoa/cocoa_v.mm15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index afbca6501..39bb2d6fe 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -258,11 +258,10 @@ static void QZ_GetDisplayModeInfo(CFArrayRef modes, CFIndex i, int &bpp, uint16
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11)
/* Extract bit depth from mode string. */
- CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode);
- if (CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 32;
- if (CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 16;
- if (CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 8;
- CFRelease(pixEnc);
+ CFAutoRelease<CFStringRef> pixEnc(CGDisplayModeCopyPixelEncoding(mode));
+ if (CFStringCompare(pixEnc.get(), CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 32;
+ if (CFStringCompare(pixEnc.get(), CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 16;
+ if (CFStringCompare(pixEnc.get(), CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) bpp = 8;
#else
/* CGDisplayModeCopyPixelEncoding is deprecated on OSX 10.11+, but there are no 8 bpp modes anyway... */
bpp = 32;
@@ -687,15 +686,13 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
void cocoaSetApplicationBundleDir()
{
char tmp[MAXPATHLEN];
- CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
- if (CFURLGetFileSystemRepresentation(url, true, (unsigned char*)tmp, MAXPATHLEN)) {
+ CFAutoRelease<CFURLRef> url(CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()));
+ if (CFURLGetFileSystemRepresentation(url.get(), true, (unsigned char*)tmp, MAXPATHLEN)) {
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_APPLICATION_BUNDLE_DIR] = stredup(tmp);
} else {
_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
}
-
- CFRelease(url);
}
/**