]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Importing: Only the main thread shall access lastFileImportErrorText
authorRoopesh Chander <roop@roopc.net>
Tue, 5 Mar 2019 10:27:11 +0000 (15:57 +0530)
committerRoopesh Chander <roop@roopc.net>
Tue, 5 Mar 2019 10:41:57 +0000 (16:11 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/TunnelImporter.swift

index 1b0fd7e58b9abef0cdcfb2acb215e321b43738ce..70e536fff85208fbd2fcd8a10ad39f03c88c9419 100644 (file)
@@ -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()
                     }