From d529c29b20feb0a1585034868c07697200a4f06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 22 Jul 2017 13:14:03 +0800 Subject: [PATCH] Delete profiles to 0 stop the app, and Not auto connect if no activeProfile --- ShadowsocksX-NG/AppDelegate.swift | 2 +- ShadowsocksX-NG/PreferencesWindowController.swift | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index e131de8..11018ac 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -201,7 +201,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele applyConfig() SyncSSLocal() - if defaults.bool(forKey: "ConnectAtLaunch") { + if defaults.bool(forKey: "ConnectAtLaunch") && ServerProfileManager.instance.getActiveProfileId() != "" { toggleRunning(toggleRunningMenuItem) } diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 09a7fbb..6865815 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -133,6 +133,9 @@ class PreferencesWindowController: NSWindowController self.profilesTableView.scrollRowToVisible(index-1) self.profilesTableView.selectRowIndexes(IndexSet(integer: index-1), byExtendingSelection: false) updateProfileBoxVisible() + if profileMgr.profiles.count == 0 { + (NSApplication.shared().delegate as! AppDelegate).toggleRunning((NSApplication.shared().delegate as! AppDelegate).toggleRunningMenuItem) + } } @IBAction func ok(_ sender: NSButton) {