aboutsummaryrefslogtreecommitdiffstats
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
commit71f7075fba978d3ad9f1450cdd33f6c862f61770 (patch)
tree836056954d14aaa83b54b2ae66c7d3480fe80570
parentmacOS: Update app icon (diff)
downloadwireguard-apple-71f7075fba978d3ad9f1450cdd33f6c862f61770.tar.xz
wireguard-apple-71f7075fba978d3ad9f1450cdd33f6c862f61770.zip
macOS: Dismiss modals correctly
Previously, the presented vc were leaking when discarding edits or when closing the log view controller.
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/LogViewController.swift5
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift16
2 files changed, 12 insertions, 9 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/LogViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/LogViewController.swift
index 81469778..088d161d 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/LogViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/LogViewController.swift
@@ -220,7 +220,8 @@ class LogViewController: NSViewController {
return
}
DispatchQueue.main.async { [weak self] in
- self?.dismiss(self)
+ guard let self = self else { return }
+ self.presentingViewController?.dismiss(self)
}
}
@@ -228,7 +229,7 @@ class LogViewController: NSViewController {
}
@objc func closeClicked() {
- dismiss(self)
+ presentingViewController?.dismiss(self)
}
@objc func copy(_ sender: Any?) {
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
index 88cabbdc..17ebbefe 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]?) {