Skip to content

Commit

Permalink
Allow _UIPopupViewController to present itself in middleware scenario…
Browse files Browse the repository at this point in the history
…s. (#1832)

A recent fix/change to UIViewController (75effb9) regressed one of our middleware scenarios. UIViewController now makes sure that one is presenting over a currently-visible ViewController. However, in middleware scenarios, that won't hold true, so we must loosen the check in such cases.

Fixes #1831.
  • Loading branch information
jaredhms authored Jan 26, 2017
1 parent f440523 commit 8959309
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Frameworks/UIKit/UIViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#import <QuartzCore/CALayer.h>
#import <QuartzCore/CoreAnimationFunctions.h>

#import "_UIPopupViewController.h"
#import "CACompositor.h"
#import "UIApplicationInternal.h"
#import "UIEmptyView.h"
#import "UIViewInternal.h"
Expand Down Expand Up @@ -1167,10 +1169,17 @@ - (void)presentViewController:(UIViewController*)controller animated:(BOOL)anima

UIViewController* visibleParent = self;
bool shouldShow = false;
do {
// Allow presentation only if an ancestor is not NotVisible.
shouldShow = visibleParent->priv->_visibility != controllerNotVisible;
} while (!shouldShow && (visibleParent = [visibleParent parentViewController]));

// We have a special case for our _UIPopupViewController in middleware scenarios; in such cases
// we won't have a visible parentViewController but we'll still want the present to succeed
if (GetCACompositor()->IsRunningAsFramework() && [self isKindOfClass:[_UIPopupViewController class]]) {
shouldShow = true;
} else {
do {
// Allow presentation only if an ancestor is not NotVisible.
shouldShow = visibleParent->priv->_visibility != controllerNotVisible;
} while (!shouldShow && (visibleParent = [visibleParent parentViewController]));
}

if (!shouldShow) {
TraceWarning(TAG, L"Controller is not visible!");
Expand Down

0 comments on commit 8959309

Please sign in to comment.