Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Fix crash when onboarding is shown before window is loaded (mac)
Browse files Browse the repository at this point in the history
Setting positioningRect when window is not yet visible may crash the app with
NSInternalInconsistencyException "window must exist".
Moved this line to delegate method, so it'll be called only after popover show
method executes successfully.
  • Loading branch information
AndrewVebster committed Oct 30, 2020
1 parent 7eb7771 commit 4618ef2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ final class OnboardingViewController: NSViewController {
preparePopoverContentView(with: payload)

popover.show(relativeTo: presentView.bounds, of: presentView, preferredEdge: payload.preferEdges)
popover.positioningRect = payload.positioningRect(payload.hint, popover.positioningRect)
}

/// Dismiss all onboard view
Expand Down Expand Up @@ -161,6 +160,11 @@ extension OnboardingViewController: NSPopoverDelegate {
func popoverWillClose(_ notification: Notification) {
delegate?.onboardingViewControllerDidClose()
}

func popoverWillShow(_ notification: Notification) {
guard let payload = payload else { return }
popover.positioningRect = payload.positioningRect(payload.hint, popover.positioningRect)
}
}

// MARK: OnboardingBackgroundViewDelegate
Expand Down

0 comments on commit 4618ef2

Please sign in to comment.