Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug 1689 - Leaks galore in OS X Cocoa code.

Edward Rudd

This is to document the various leaks I'm finding in the Cocoa code in SDL 2.
  • Loading branch information
slouken committed Feb 8, 2013
1 parent e740ffe commit 39aa247226f32b8116b7512fd89b633e39fba48c
@@ -107,6 +107,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
[menuItem setSubmenu:serviceMenu];

[NSApp setServicesMenu:serviceMenu];
[serviceMenu release];

[appleMenu addItem:[NSMenuItem separatorItem]];

@@ -56,7 +56,7 @@
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
int i;
for (i = 0; i < messageboxdata->numbuttons; ++i) {
NSButton *button = [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
[button setKeyEquivalent:@"\r"];
} else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
@@ -225,11 +225,13 @@ - (void) setFrame:(NSRect)frame;
{
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];

const char* displayName = NULL;

if ([localizedNames count] > 0) {
return [[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String];
displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]);
}
return NULL;
[deviceInfo release];
return displayName;
}

void
@@ -302,9 +304,11 @@ - (void) setFrame:(NSRect)frame;
displaydata->display = displays[i];

SDL_zero(display);
// this returns a stddup'ed string
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
if (!GetDisplayMode (_this, moderef, &mode)) {
Cocoa_ReleaseDisplayMode(_this, moderef);
if (display.name) SDL_free(display.name);
SDL_free(displaydata);
continue;
}
@@ -313,6 +317,7 @@ - (void) setFrame:(NSRect)frame;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
if (display.name) SDL_free(display.name);
}
}
SDL_stack_free(displays);
@@ -273,6 +273,7 @@ void SDL_NSLog(const char *text)
[alert addButtonWithTitle:@"Ignore"];
[alert addButtonWithTitle:@"Always Ignore"];
const NSInteger clicked = [alert runModal];
[alert release];

if (!initialized) {
SDL_QuitSubSystem(SDL_INIT_VIDEO);

0 comments on commit 39aa247

Please sign in to comment.