From bde984625cf935162404387c184030b44b8de02d Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Tue, 11 Dec 2018 17:48:34 +0530 Subject: State restoration: Don't create duplicate mainVC and tunnelsListVC This creates a duplicate tunnels manager, leading to problems tracking tunnel statuses. To reproduce the bug that this commit fixes, you can do the following: 1. Remove all tunnels 2. Run in Xcode 3. Import zip with ~10 tunnels 4. Stop app in Xcode 5. Run in Xcode 6. Turn on 1st tunnel, after it's on, turn off Turn on 2nd tunnel, after it's on, turn off ... After 6-8 tunnels, the spinner doesn't show up, indicating that the status is not being tracked. Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/UI/iOS/AppDelegate.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'WireGuard/WireGuard/UI/iOS') diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift index 3116f7a..5dca2ad 100644 --- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift @@ -52,11 +52,7 @@ extension AppDelegate { viewControllerWithRestorationIdentifierPath identifierComponents: [String], coder: NSCoder) -> UIViewController? { guard let vcIdentifier = identifierComponents.last else { return nil } - if (vcIdentifier == "MainVC") { - return MainViewController() - } else if (vcIdentifier == "TunnelsListVC") { - return TunnelsListTableViewController() - } else if (vcIdentifier.hasPrefix("TunnelDetailVC:")) { + if (vcIdentifier.hasPrefix("TunnelDetailVC:")) { let tunnelName = String(vcIdentifier.suffix(vcIdentifier.count - "TunnelDetailVC:".count)) if let tunnelsManager = mainVC?.tunnelsManager { if let tunnel = tunnelsManager.tunnel(named: tunnelName) { @@ -66,7 +62,6 @@ extension AppDelegate { // Show it when tunnelsManager is available mainVC?.showTunnelDetailForTunnel(named: tunnelName, animated: false) } - } return nil } -- cgit v1.2.3-59-g8ed1b