Fixed a crash on iOS when none of the orientations in Info.plist match the SDL window's actual orientation. Fixes bug #2967.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index 747f150..d680b49 100755
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -1082,7 +1082,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0630;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDL" */;
compatibilityVersion = "Xcode 3.2";
@@ -1253,7 +1253,8 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
+ ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
@@ -1265,7 +1266,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
@@ -1278,10 +1279,10 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
COPY_PHASE_STRIP = NO;
- IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
@@ -1294,10 +1295,10 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
COPY_PHASE_STRIP = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index e65732c..4010ca6 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -191,13 +191,10 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
}
if (data.uiscreen == [UIScreen mainScreen]) {
- NSUInteger orientations = UIKit_GetSupportedOrientations(window);
- UIApplication *app = [UIApplication sharedApplication];
-
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
- app.statusBarHidden = YES;
+ [UIApplication sharedApplication].statusBarHidden = YES;
} else {
- app.statusBarHidden = NO;
+ [UIApplication sharedApplication].statusBarHidden = NO;
}
}
@@ -345,9 +342,21 @@ NSUInteger
UIKit_GetSupportedOrientations(SDL_Window * window)
{
const char *hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
+ NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
NSUInteger orientationMask = 0;
@autoreleasepool {
+ SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
+ UIApplication *app = [UIApplication sharedApplication];
+
+ /* Get all possible valid orientations. If the app delegate doesn't tell
+ * us, we get the orientations from Info.plist via UIApplication. */
+ if ([app.delegate respondsToSelector:@selector(application:supportedInterfaceOrientationsForWindow:)]) {
+ validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
+ } else if ([app respondsToSelector:@selector(supportedInterfaceOrientationsForWindow:)]) {
+ validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
+ }
+
if (hint != NULL) {
NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
@@ -379,10 +388,17 @@ UIKit_GetSupportedOrientations(SDL_Window * window)
}
}
- /* Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation */
+ /* Don't allow upside-down orientation on phones, so answering calls is in the natural orientation */
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
}
+
+ /* If none of the specified orientations are actually supported by the
+ * app, we'll revert to what the app supports. An exception would be
+ * thrown by the system otherwise. */
+ if ((validOrientations & orientationMask) == 0) {
+ orientationMask = validOrientations;
+ }
}
return orientationMask;