Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters.

This commit is contained in:
Philipp Wiesemann 2016-06-26 21:08:57 +02:00
parent f4d33fcbba
commit 2f016cf88d
1 changed files with 9 additions and 3 deletions

View File

@ -323,9 +323,15 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
size_t pixelWidth = CGDisplayPixelsWide(data->display); size_t pixelWidth = CGDisplayPixelsWide(data->display);
size_t pixelHeight = CGDisplayPixelsHigh(data->display); size_t pixelHeight = CGDisplayPixelsHigh(data->display);
*ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH); if (ddpi) {
*hdpi = pixelWidth * MM_IN_INCH / displaySize.width; *ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH);
*vdpi = pixelHeight * MM_IN_INCH / displaySize.height; }
if (hdpi) {
*hdpi = pixelWidth * MM_IN_INCH / displaySize.width;
}
if (vdpi) {
*vdpi = pixelHeight * MM_IN_INCH / displaySize.height;
}
return 0; return 0;
} }