From cadae2170bdeffd92189c06c2c5655d5c1d7e7a9 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 28 Feb 2023 19:41:02 +0200 Subject: [PATCH] Revert "Fix bug in which teardowns can be called multiple times on the same coordinator" This reverts commit 4ae3b3b2dba033d560fe5321686635c96bd53f95. --- .../Navigation/NavigationCoordinators.swift | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift index 80599a862..52cec3f64 100644 --- a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift +++ b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift @@ -229,13 +229,15 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS /// /// For added complexity, the NavigationSplitCoordinator has an internal compact layout NavigationStack for which we need to manually nil things again private func releaseAllCoordinatorReferences() { - sidebarModule = nil - detailModule = nil - sheetModule = nil - fullScreenCoverModule = nil + sidebarModule?.tearDown() + detailModule?.tearDown() + sheetModule?.tearDown() + fullScreenCoverModule?.tearDown() - compactLayoutRootModule = nil - compactLayoutStackModules.removeAll() + compactLayoutRootModule?.tearDown() + compactLayoutStackModules.forEach { module in + module.tearDown() + } } private func logPresentationChange(_ change: String, _ module: NavigationModule) { @@ -624,10 +626,13 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS /// when a NavigationModule is dismissed. As the NavigationModule is just a wrapper multiple instances of it continuing living is of no consequence /// https://stackoverflow.com/questions/73885353/found-a-strange-behaviour-of-state-when-combined-to-the-new-navigation-stack/ func stop() { - rootModule = nil - sheetModule = nil - fullScreenCoverModule = nil - stackModules.removeAll() + rootModule?.tearDown() + sheetModule?.tearDown() + fullScreenCoverModule?.tearDown() + + stackModules.forEach { module in + module.tearDown() + } } // MARK: - CustomStringConvertible