Skip to content

Commit

Permalink
Merge pull request #6205 from vishalduggal/timob-17712-34X
Browse files Browse the repository at this point in the history
[TIMOB-17712] (3_4_X) iOS8: Avoid race condition on dismissal of modal window
  • Loading branch information
jonalter committed Oct 7, 2014
2 parents f3863b9 + 932f733 commit a48d448
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions iphone/Classes/TiRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
-(void)incrementActiveAlertControllerCount;
-(void)decrementActiveAlertControllerCount;
-(UIViewController*)topPresentedController;
-(UIInterfaceOrientation) lastValidOrientation:(TiOrientationFlags)orientationFlags;
-(void)updateStatusBar;
@property (nonatomic, readonly) BOOL statusBarInitiallyHidden;
@property (nonatomic, readonly) UIStatusBarStyle defaultStatusBarStyle;
Expand Down
24 changes: 12 additions & 12 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1015,18 +1015,19 @@ -(void)repositionSubviews
*/
}

-(UIInterfaceOrientation) lastValidOrientation:(BOOL)checkModal
-(UIInterfaceOrientation) lastValidOrientation:(TiOrientationFlags)orientationFlags
{
if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:checkModal]) {
if (TI_ORIENTATION_ALLOWED(orientationFlags,deviceOrientation)) {
return deviceOrientation;
}
for (int i = 0; i<4; i++) {
if ([self shouldRotateToInterfaceOrientation:orientationHistory[i] checkModal:checkModal]) {
return orientationHistory[i];
}
}
//This line should never happen, but just in case...
return UIInterfaceOrientationPortrait;
if (TI_ORIENTATION_ALLOWED(orientationFlags,orientationHistory[i])) {
return orientationHistory[i];
}
}

//This line should never happen, but just in case...
return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation checkModal:(BOOL)check
Expand Down Expand Up @@ -1185,7 +1186,7 @@ - (NSUInteger)supportedInterfaceOrientations{

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self lastValidOrientation:YES];
return [self lastValidOrientation:[self getFlags:NO]];
}

-(void)didOrientNotify:(NSNotification *)notification
Expand All @@ -1196,7 +1197,6 @@ -(void)didOrientNotify:(NSNotification *)notification
return;
}
deviceOrientation = (UIInterfaceOrientation) newOrientation;

if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:NO]) {
[self resetTransformAndForceLayout:YES];
[self updateOrientationHistory:deviceOrientation];
Expand All @@ -1215,7 +1215,7 @@ -(void)refreshOrientationWithDuration:(id)unused
return;
}

UIInterfaceOrientation target = [self lastValidOrientation:NO];
UIInterfaceOrientation target = [self lastValidOrientation:[self getFlags:NO]];
//Device Orientation takes precedence.
if (target != deviceOrientation) {
if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:NO]) {
Expand Down Expand Up @@ -1541,7 +1541,7 @@ -(void)viewDidAppear:(BOOL)animated
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow viewDidAppear:animated];
}
if (forcingRotation) {
if (forcingRotation || [TiUtils isIOS8OrGreater]) {
forcingRotation = NO;
[self performSelector:@selector(childOrientationControllerChangedFlags:) withObject:[containedWindows lastObject] afterDelay:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]];
} else {
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (NSUInteger)supportedInterfaceOrientations {

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[[TiApp app] controller] preferredInterfaceOrientationForPresentation];
return [[[TiApp app] controller] lastValidOrientation:_supportedOrientations];
}

-(void)loadView
Expand Down

0 comments on commit a48d448

Please sign in to comment.