Prevent crash on add and deletion of config.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts 2018-09-15 21:23:47 +02:00
parent b8abaa5283
commit 3a8f8ef9e6
1 changed files with 31 additions and 24 deletions

View File

@ -328,6 +328,7 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
}
func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
_ = refreshProviderManagers().then { () -> Promise<Void> in
let manager = self.providerManager(for: tunnel)!
let block = {
switch manager.connection.status {
@ -345,9 +346,13 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
} else {
block()
}
return Promise.value(())
}
}
func disconnect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
_ = refreshProviderManagers().then { () -> Promise<Void> in
let manager = self.providerManager(for: tunnel)!
let block = {
switch manager.connection.status {
@ -365,6 +370,8 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
} else {
block()
}
return Promise.value(())
}
}
private func connect(tunnel: Tunnel) {