Skip to content

Commit cdac7d8

Browse files
authored
Merge pull request #8540 from woocommerce/crash/8539-fix-dashboard-header-crash
Reset Auto Layout constraint that pins to a view that is being removed to fix a crash
2 parents d5b81b1 + be35f31 commit cdac7d8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/DashboardViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,12 @@ private extension DashboardViewController {
543543
return
544544
}
545545

546+
// Resets the Auto Layout constraint that pins the previous content view to the bottom of the header view.
547+
// Otherwise, if `contentTopToHeaderConstraint?.isActive = true` is called after the previous content view is removed
548+
// in the next line `remove(previousDashboardUI)`, the app crashes because the content view is no longer in the
549+
// view hierarchy.
550+
contentTopToHeaderConstraint = nil
551+
546552
// Tears down the previous child view controller.
547553
if let previousDashboardUI = dashboardUI {
548554
remove(previousDashboardUI)

0 commit comments

Comments
 (0)