Skip to content

Commit

Permalink
Merge pull request #4493 from wikimedia/T280700
Browse files Browse the repository at this point in the history
Table of Contents iPad crash fix
  • Loading branch information
staykids authored Mar 22, 2023
2 parents aa7ab4f + 108d75e commit 71f3985
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Wikipedia/Code/ArticleTableOfContentsDisplayController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ class ArticleTableOfContentsDisplayController: Themeable {
self.viewController.isVisible = true
self.selectAndScroll(to: sectionId, animated: false)

// Attempt to fix TOC presentation crashes.
guard !self.viewController.isBeingPresented && self.delegate !== self.viewController else {
// Attempts to fix TOC presentation crashes. Error message target is in comments.
guard
!self.viewController.isBeingPresented && // Application tried to present modally a view controller %@ that is already being presented by %@.
self.delegate?.presentedViewController == nil && // Attempt to present %@ on %@ (from %@) which is already presenting %@.
self.delegate !== self.viewController && // Application tried to present modal view controller on itself.
self.viewController.parent == nil && // Application tried to present modally a view controller %@ that has a parent view controller %@.
(self.delegate?.isViewLoaded ?? false) // Attempt to present %@ on %@ (from %@) whose view is not in the window hierarchy.
else {
return
}

Expand Down Expand Up @@ -180,5 +186,4 @@ class ArticleTableOfContentsDisplayController: Themeable {
viewController.selectItem(at: index)
viewController.scrollToItem(at: index)
}

}

0 comments on commit 71f3985

Please sign in to comment.