aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-05-29 19:45:22 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-31 17:29:29 +0200
commit714d6a41bd2669515181552104a5c587064ae3ea (patch)
tree836056954d14aaa83b54b2ae66c7d3480fe80570 /WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
parentmacOS: Update app icon (diff)
downloadwireguard-apple-714d6a41bd2669515181552104a5c587064ae3ea.tar.xz
wireguard-apple-714d6a41bd2669515181552104a5c587064ae3ea.zip
macOS: Dismiss modals correctly
Previously, the presented vc were leaking when discarding edits or when closing the log view controller. Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift16
1 files changed, 9 insertions, 7 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
index 88cabbd..17ebbef 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
@@ -237,24 +237,26 @@ class TunnelEditViewController: NSViewController {
if let tunnel = tunnel {
// We're modifying an existing tunnel
tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, onDemandOption: onDemandOption) { [weak self] error in
- self?.setUserInteractionEnabled(true)
+ guard let self = self else { return }
+ self.setUserInteractionEnabled(true)
if let error = error {
ErrorPresenter.showErrorAlert(error: error, from: self)
return
}
- self?.dismiss(self)
- self?.delegate?.tunnelSaved(tunnel: tunnel)
+ self.delegate?.tunnelSaved(tunnel: tunnel)
+ self.presentingViewController?.dismiss(self)
}
} else {
// We're creating a new tunnel
self.tunnelsManager.add(tunnelConfiguration: tunnelConfiguration, onDemandOption: onDemandOption) { [weak self] result in
- self?.setUserInteractionEnabled(true)
+ guard let self = self else { return }
+ self.setUserInteractionEnabled(true)
switch result {
case .failure(let error):
ErrorPresenter.showErrorAlert(error: error, from: self)
case .success(let tunnel):
- self?.dismiss(self)
- self?.delegate?.tunnelSaved(tunnel: tunnel)
+ self.delegate?.tunnelSaved(tunnel: tunnel)
+ self.presentingViewController?.dismiss(self)
}
}
}
@@ -262,7 +264,7 @@ class TunnelEditViewController: NSViewController {
@objc func handleDiscardAction() {
delegate?.tunnelEditingCancelled()
- dismiss(self)
+ presentingViewController?.dismiss(self)
}
func updateExcludePrivateIPsVisibility(singlePeerAllowedIPs: [String]?) {