Assert that snapshot view obscures GL view when it exists

Just in case the host app mucks around with `MGLView`’s internal view hierarchy.
This commit is contained in:
Minh Nguyễn
2015-04-15 10:18:15 -07:00
parent e19b6afb26
commit ec987ca434

View File

@@ -562,7 +562,16 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
// This is the delegate of the GLKView object's display call.
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
if (!self.glSnapshotView)
if (self.glSnapshotView)
{
NSUInteger snapshotIdx = [self.subviews indexOfObject:self.glSnapshotView];
NSUInteger glIdx = [self.subviews indexOfObject:self.glView];
NSAssert(snapshotIdx > glIdx,
@"The snapshot view is the %luth subview, behind the GL view, which is the %luth. "
@"The snapshot view should obscure the GL view to prevent crashing while the app is in the background.",
(unsigned long)snapshotIdx, (unsigned long)glIdx);
}
else
{
mbglView->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight);
mbglMap->renderSync();