Bugfix use a singleton ServerProfileManager

This commit is contained in:
C.S
2016-06-18 13:38:58 +08:00
parent 78bb0b7d32
commit 94e065ea63
4 changed files with 9 additions and 8 deletions

View File

@ -81,7 +81,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if let userInfo = note.userInfo {
let urls: [NSURL] = userInfo["urls"] as! [NSURL]
let mgr = ServerProfileManager()
let mgr = ServerProfileManager.instance
var isChanged = false
for url in urls {
@ -191,8 +191,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
@IBAction func showQRCodeForCurrentServer(sender: NSMenuItem) {
var errMsg: String?
let mgr = ServerProfileManager()
if let profile = mgr.getActiveProfile() {
if let profile = ServerProfileManager.instance.getActiveProfile() {
if profile.isValid() {
// Show window
if qrcodeWinCtrl != nil{
@ -275,7 +274,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
@IBAction func selectServer(sender: NSMenuItem) {
let index = sender.tag
let spMgr = ServerProfileManager()
let spMgr = ServerProfileManager.instance
let newProfile = spMgr.profiles[index]
if newProfile.uuid != spMgr.activeProfileId {
spMgr.setActiveProfiledId(newProfile.uuid)
@ -345,7 +344,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
func updateServersMenu() {
let mgr = ServerProfileManager()
let mgr = ServerProfileManager.instance
serversMenuItem.submenu?.removeAllItems()
let preferencesItem = serversPreferencesMenuItem