using GDC aync to avoid freeze of operation on show current QR

This commit is contained in:
秦宇航
2017-04-12 23:22:28 +08:00
parent 2ef8cdb798
commit ff618dd0f5
+11 -8
View File
@@ -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