From: Roopesh Chander Date: Tue, 5 Mar 2019 10:27:11 +0000 (+0530) Subject: Importing: Only the main thread shall access lastFileImportErrorText X-Git-Tag: 0.0.20190319-1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe4f8b666d0d2c3b532ee145e205a30a4ad56b82;p=thirdparty%2Fwireguard-apple.git Importing: Only the main thread shall access lastFileImportErrorText Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/WireGuard/UI/TunnelImporter.swift b/WireGuard/WireGuard/UI/TunnelImporter.swift index 1b0fd7e..70e536f 100644 --- a/WireGuard/WireGuard/UI/TunnelImporter.swift +++ b/WireGuard/WireGuard/UI/TunnelImporter.swift @@ -33,22 +33,22 @@ class TunnelImporter { do { fileContents = try String(contentsOf: url) } catch let error { - if let cocoaError = error as? CocoaError, cocoaError.isFileError { - lastFileImportErrorText = (title: tr("alertCantOpenInputConfFileTitle"), message: error.localizedDescription) - } else { - lastFileImportErrorText = (title: tr("alertCantOpenInputConfFileTitle"), message: tr(format: "alertCantOpenInputConfFileMessage (%@)", fileName)) - } DispatchQueue.main.async { + if let cocoaError = error as? CocoaError, cocoaError.isFileError { + lastFileImportErrorText = (title: tr("alertCantOpenInputConfFileTitle"), message: error.localizedDescription) + } else { + lastFileImportErrorText = (title: tr("alertCantOpenInputConfFileTitle"), message: tr(format: "alertCantOpenInputConfFileMessage (%@)", fileName)) + } configs.append(nil) dispatchGroup.leave() } return } let tunnelConfiguration = try? TunnelConfiguration(fromWgQuickConfig: fileContents, called: fileBaseName) - if tunnelConfiguration == nil { - lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName)) - } DispatchQueue.main.async { + if tunnelConfiguration == nil { + lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName)) + } configs.append(tunnelConfiguration) dispatchGroup.leave() }