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.
This commit is contained in:
parent
079d0ee977
commit
352adba2df
4 changed files with 11 additions and 4 deletions
|
@ -107,6 +107,7 @@ CreateApplicationMenus(void)
|
||||||
[menuItem setSubmenu:serviceMenu];
|
[menuItem setSubmenu:serviceMenu];
|
||||||
|
|
||||||
[NSApp setServicesMenu:serviceMenu];
|
[NSApp setServicesMenu:serviceMenu];
|
||||||
|
[serviceMenu release];
|
||||||
|
|
||||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
|
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < messageboxdata->numbuttons; ++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) {
|
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||||
[button setKeyEquivalent:@"\r"];
|
[button setKeyEquivalent:@"\r"];
|
||||||
} else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
} else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
||||||
|
|
|
@ -225,11 +225,13 @@ Cocoa_GetDisplayName(CGDirectDisplayID displayID)
|
||||||
{
|
{
|
||||||
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
|
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
|
||||||
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||||
|
const char* displayName = NULL;
|
||||||
|
|
||||||
if ([localizedNames count] > 0) {
|
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
|
void
|
||||||
|
@ -302,9 +304,11 @@ Cocoa_InitModes(_THIS)
|
||||||
displaydata->display = displays[i];
|
displaydata->display = displays[i];
|
||||||
|
|
||||||
SDL_zero(display);
|
SDL_zero(display);
|
||||||
|
// this returns a stddup'ed string
|
||||||
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
|
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
|
||||||
if (!GetDisplayMode (_this, moderef, &mode)) {
|
if (!GetDisplayMode (_this, moderef, &mode)) {
|
||||||
Cocoa_ReleaseDisplayMode(_this, moderef);
|
Cocoa_ReleaseDisplayMode(_this, moderef);
|
||||||
|
if (display.name) SDL_free(display.name);
|
||||||
SDL_free(displaydata);
|
SDL_free(displaydata);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -313,6 +317,7 @@ Cocoa_InitModes(_THIS)
|
||||||
display.current_mode = mode;
|
display.current_mode = mode;
|
||||||
display.driverdata = displaydata;
|
display.driverdata = displaydata;
|
||||||
SDL_AddVideoDisplay(&display);
|
SDL_AddVideoDisplay(&display);
|
||||||
|
if (display.name) SDL_free(display.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_stack_free(displays);
|
SDL_stack_free(displays);
|
||||||
|
|
|
@ -273,6 +273,7 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
|
||||||
[alert addButtonWithTitle:@"Ignore"];
|
[alert addButtonWithTitle:@"Ignore"];
|
||||||
[alert addButtonWithTitle:@"Always Ignore"];
|
[alert addButtonWithTitle:@"Always Ignore"];
|
||||||
const NSInteger clicked = [alert runModal];
|
const NSInteger clicked = [alert runModal];
|
||||||
|
[alert release];
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue