Skip to content

Commit 8036d99

Browse files
committed
4.2.1 修复配置页面死锁崩溃
1 parent 2d5030e commit 8036d99

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

Podfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ target 'V2rayU' do
99

1010
# Pods for V2rayU
1111
pod 'FirebaseAnalytics', '~> 10.24.0'
12-
pod 'FirebaseCrashlytics'
13-
pod 'SwiftyJSON'/
12+
pod 'FirebaseCrashlytics', '~> 10.24.0'
13+
pod 'SwiftyJSON'
1414
# master branch
1515
pod 'Preferences', :git => 'https://github.com/sindresorhus/Preferences.git'
1616
pod 'QRCoder'

Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ PODS:
117117

118118
DEPENDENCIES:
119119
- FirebaseAnalytics (~> 10.24.0)
120-
- FirebaseCrashlytics
120+
- FirebaseCrashlytics (~> 10.24.0)
121121
- MASShortcut
122122
- Preferences (from `https://github.com/sindresorhus/Preferences.git`)
123123
- QRCoder
@@ -178,6 +178,6 @@ SPEC CHECKSUMS:
178178
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
179179
Yams: e10dae147f517ed57ecae37c5e8681bdf8fcab65
180180

181-
PODFILE CHECKSUM: d61ad825ad5d61b2b98237544e21946c9babe3a0
181+
PODFILE CHECKSUM: 94ab23e73805bd5279654adc5ea4b4c31f94b8af
182182

183183
COCOAPODS: 1.15.2

V2rayU.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@
851851
"@executable_path/../Frameworks",
852852
);
853853
MACOSX_DEPLOYMENT_TARGET = 11.0;
854-
MARKETING_VERSION = 4.2.0;
854+
MARKETING_VERSION = 4.2.1;
855855
ONLY_ACTIVE_ARCH = YES;
856856
PRODUCT_BUNDLE_IDENTIFIER = net.yanue.V2rayU;
857857
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -886,7 +886,7 @@
886886
"@executable_path/../Frameworks",
887887
);
888888
MACOSX_DEPLOYMENT_TARGET = 11.0;
889-
MARKETING_VERSION = 4.2.0;
889+
MARKETING_VERSION = 4.2.1;
890890
ONLY_ACTIVE_ARCH = NO;
891891
PRODUCT_BUNDLE_IDENTIFIER = net.yanue.V2rayU;
892892
PRODUCT_NAME = "$(TARGET_NAME)";

V2rayU/ConfigWindow.swift

+16-17
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel
176176
// add
177177
V2rayServer.add()
178178

179-
DispatchQueue.main.sync {
179+
DispatchQueue.main.async {
180180
V2rayServer.loadConfig()
181181
// reload data
182182
self.serversTableView.reloadData()
@@ -187,7 +187,7 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel
187187

188188
// delete server config
189189
case 1:
190-
DispatchQueue.main.sync {
190+
DispatchQueue.main.async {
191191
// get seleted index
192192
let idx = self.serversTableView.selectedRow
193193
// remove
@@ -562,7 +562,7 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel
562562

563563
v2rayConfig.parseJson(jsonText: self.configText.string)
564564
if v2rayConfig.errors.count > 0 {
565-
DispatchQueue.main.sync {
565+
DispatchQueue.main.async {
566566
self.errTip.stringValue = v2rayConfig.errors[0]
567567
}
568568
}
@@ -579,7 +579,7 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel
579579
}
580580
self.refreshServerList(ok: errMsg.count == 0)
581581
} else {
582-
DispatchQueue.main.sync {
582+
DispatchQueue.main.async {
583583
self.errTip.stringValue = errMsg
584584
}
585585
}
@@ -898,27 +898,27 @@ extension ConfigWindowController: NSTableViewDataSource {
898898
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
899899
let v2rayItemList = V2rayServer.list()
900900
// set cell data
901-
if v2rayItemList.count >= row {
901+
if row < v2rayItemList.count {
902902
return v2rayItemList[row].remark
903903
}
904904
return nil
905905
}
906906

907907
// edit cell
908-
func tableView(_ tableView: NSTableView, setObjectValue: Any?, for forTableColumn: NSTableColumn?, row: Int) {
908+
func tableView(_ tableView: NSTableView, setObjectValue: Any?, for tableColumn: NSTableColumn?, row: Int) {
909909
guard let remark = setObjectValue as? String else {
910910
NSLog("remark is nil")
911911
return
912912
}
913913
DispatchQueue.global().async {
914914
// edit item remark
915915
V2rayServer.edit(rowIndex: row, remark: remark)
916-
// reload table
916+
// reload table on main thread
917917
DispatchQueue.main.async {
918918
tableView.reloadData()
919+
// reload menu
920+
menuController.showServers()
919921
}
920-
// reload menu
921-
menuController.showServers()
922922
}
923923
}
924924
}
@@ -942,25 +942,24 @@ extension ConfigWindowController: NSTableViewDelegate {
942942
if dropOperation == .above {
943943
return .move
944944
}
945-
return NSDragOperation()
945+
return []
946946
}
947947

948948
func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
949949
var oldIndexes = [Int]()
950-
info.enumerateDraggingItems(options: [], for: tableView, classes: [NSPasteboardItem.self], searchOptions: [:], using: {
951-
(draggingItem: NSDraggingItem, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) in
950+
info.enumerateDraggingItems(options: [], for: tableView, classes: [NSPasteboardItem.self], searchOptions: [:]) { (draggingItem, _, _) in
952951
if let str = (draggingItem.item as! NSPasteboardItem).string(forType: NSPasteboard.PasteboardType(rawValue: self.tableViewDragType)),
953952
let index = Int(str) {
954953
oldIndexes.append(index)
955954
}
956-
})
955+
}
957956

958957
var oldIndexOffset = 0
959958
var newIndexOffset = 0
960959
var oldIndexLast = 0
961960
var newIndexLast = 0
962961

963-
// For simplicity, the code below uses `tableView.moveRowAtIndex` to move rows around directly.
962+
// For simplicity, the code below uses `tableView.moveRow(at:to:)` to move rows around directly.
964963
// You may want to move rows in your content array and then call `tableView.reloadData()` instead.
965964
for oldIndex in oldIndexes {
966965
if oldIndex < row {
@@ -978,12 +977,12 @@ extension ConfigWindowController: NSTableViewDelegate {
978977
V2rayServer.move(oldIndex: oldIndexLast, newIndex: newIndexLast)
979978
DispatchQueue.main.async {
980979
// set selected
981-
self.serversTableView.selectRowIndexes(NSIndexSet(index: newIndexLast) as IndexSet, byExtendingSelection: false)
980+
self.serversTableView.selectRowIndexes(IndexSet(integer: newIndexLast), byExtendingSelection: false)
982981
// reload table
983982
self.serversTableView.reloadData()
983+
// reload menu
984+
menuController.showServers()
984985
}
985-
// reload menu
986-
menuController.showServers()
987986
}
988987
return true
989988
}

V2rayU/Preference/PreferenceRouting.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ final class PreferenceRoutingViewController: NSViewController, PreferencePane, N
9292
// add
9393
V2rayRoutings.add(remark: "new-rule", json: V2rayRoutings.default_rule_content)
9494

95-
DispatchQueue.main.sync {
95+
DispatchQueue.main.async {
9696
V2rayRoutings.loadConfig()
9797
// reload data
9898
self.routingsTableView.reloadData()
@@ -103,7 +103,7 @@ final class PreferenceRoutingViewController: NSViewController, PreferencePane, N
103103

104104
// delete server config
105105
case 1:
106-
DispatchQueue.main.sync {
106+
DispatchQueue.main.async {
107107
// get seleted index
108108
let idx = self.routingsTableView.selectedRow
109109
// remove

0 commit comments

Comments
 (0)