src/video/cocoa/SDL_cocoamodes.m
changeset 6836 b0ca1571caf3
parent 6809 54cca01b6006
child 6885 700f1b25f77f
     1.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Tue Feb 05 12:10:54 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Fri Feb 08 00:54:08 2013 -0800
     1.3 @@ -225,11 +225,13 @@
     1.4  {
     1.5      NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
     1.6      NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
     1.7 -
     1.8 +    const char* displayName = NULL;
     1.9 +    
    1.10      if ([localizedNames count] > 0) {
    1.11 -        return [[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String];
    1.12 +        displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]);
    1.13      }
    1.14 -    return NULL;
    1.15 +    [deviceInfo release];
    1.16 +    return displayName;
    1.17  }
    1.18  
    1.19  void
    1.20 @@ -302,9 +304,11 @@
    1.21              displaydata->display = displays[i];
    1.22  
    1.23              SDL_zero(display);
    1.24 +            // this returns a stddup'ed string
    1.25              display.name = (char *)Cocoa_GetDisplayName(displays[i]);
    1.26              if (!GetDisplayMode (_this, moderef, &mode)) {
    1.27                  Cocoa_ReleaseDisplayMode(_this, moderef);
    1.28 +                if (display.name) SDL_free(display.name);
    1.29                  SDL_free(displaydata);
    1.30                  continue;
    1.31              }
    1.32 @@ -313,6 +317,7 @@
    1.33              display.current_mode = mode;
    1.34              display.driverdata = displaydata;
    1.35              SDL_AddVideoDisplay(&display);
    1.36 +            if (display.name) SDL_free(display.name);
    1.37          }
    1.38      }
    1.39      SDL_stack_free(displays);