• Sam Lantinga's avatar
    Fixed bug 1239 - Crash in iPad with iOS 3.2 because of missing contentScaleFactor support · de93e295
    Sam Lantinga authored
    Joseba García Echebarria 2011-06-30 19:03:56 PDT
    I just found that SDL is crashing in the iPad simulator for iOS 3.2 but not for
    iOS 4.2 or over when compiling with Xcode 4.0.2.
    The Xcode debugger points to line 127 in video/uikit/SDL_uikitopenglview.m as
    the line that triggers the crash.
    On those lines one can find:
    
            /* Use the main screen scale (for retina display support) */
            if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
                    self.contentScaleFactor = [UIScreen mainScreen].scale;
    
    I believe the problem to be that the "scale" selector is supported in iOS 3.2
    in the iPad, but contentScaleFactor is not.
    I'm no expert in Objective-C, but I believe the following code to be more
    correct (it doesn't crash for me):
            /* Use the main screen scale (for retina display support) */
            if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] &&
    [self respondsToSelector:@selector(contentScaleFactor)])
                    self.contentScaleFactor = [UIScreen mainScreen].scale;
    
    The same check is being performed in line 155 so I imagine it will crash there,
    too.
    
    Vittorio Giovara 2011-08-22 17:58:20 PDT
    
    yeah, -scale was introduced in 3.2 but made available only in 4.0, weird
    anyways we just need to check against contentScaleFactor as we can be sure that
    both are availble starting from 4.0
    
    the attached patch addresses this
    de93e295
Name
Last commit
Last update
VisualC Loading commit data...
Xcode Loading commit data...
Xcode-iOS Loading commit data...
acinclude Loading commit data...
android-project Loading commit data...
build-scripts Loading commit data...
include Loading commit data...
src Loading commit data...
test Loading commit data...
.DISABLED-hgeol Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
.indent.pro Loading commit data...
Android.mk Loading commit data...
BUGS Loading commit data...
Borland.html Loading commit data...
Borland.zip Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
INSTALL Loading commit data...
Makefile.ds Loading commit data...
Makefile.in Loading commit data...
Makefile.minimal Loading commit data...
Makefile.pandora Loading commit data...
Makefile.wiz Loading commit data...
NOTES Loading commit data...
README Loading commit data...
README-SDL.txt Loading commit data...
README.BeOS Loading commit data...
README.DirectFB Loading commit data...
README.HG Loading commit data...
README.MacOSX Loading commit data...
README.Platforms Loading commit data...
README.Porting Loading commit data...
README.Watcom Loading commit data...
README.WinCE Loading commit data...
README.android Loading commit data...
README.ds Loading commit data...
README.gesture Loading commit data...
README.iOS Loading commit data...
README.pandora Loading commit data...
README.touch Loading commit data...
SDL.spec.in Loading commit data...
TODO Loading commit data...
UNDER_CONSTRUCTION.txt Loading commit data...
VisualC.html Loading commit data...
Watcom-Win32.zip Loading commit data...
WhatsNew Loading commit data...
aclocal.m4 Loading commit data...
autogen.sh Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
sdl-config.in Loading commit data...
sdl.m4 Loading commit data...
sdl.pc.in Loading commit data...