From ff618dd0f5ba3d6d1a5d9cfb462ed3f4ef84770b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Wed, 12 Apr 2017 23:22:28 +0800 Subject: [PATCH] using GDC aync to avoid freeze of operation on show current QR --- ShadowsocksX-NG/AppDelegate.swift | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 9f8196f..8f9e0b4 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -300,15 +300,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele if let profile = ServerProfileManager.instance.getActiveProfile() { if profile.isValid() { // Show window - if qrcodeWinCtrl != nil{ - qrcodeWinCtrl.close() + DispatchQueue.global().async { + if self.qrcodeWinCtrl != nil{ + self.qrcodeWinCtrl.close() + } + self.qrcodeWinCtrl = SWBQRCodeWindowController(windowNibName: "SWBQRCodeWindowController") + self.qrcodeWinCtrl.qrCode = profile.URL()!.absoluteString + DispatchQueue.main.async { + self.qrcodeWinCtrl.showWindow(self) + NSApp.activate(ignoringOtherApps: true) + self.qrcodeWinCtrl.window?.makeKeyAndOrderFront(nil) + } } - qrcodeWinCtrl = SWBQRCodeWindowController(windowNibName: "SWBQRCodeWindowController") - qrcodeWinCtrl.qrCode = profile.URL()!.absoluteString - qrcodeWinCtrl.showWindow(self) - NSApp.activate(ignoringOtherApps: true) - qrcodeWinCtrl.window?.makeKeyAndOrderFront(nil) - return } else { errMsg = "Current server profile is not valid.".localized