Partially enable Swift concurrency checks

This commit is contained in:
Damiano Galassi committed 2024-06-27 11:57:20 +02:00
1 parent e08b65a43b
commit fc6bc09ce2
12 files changed
+43 -45

No files matched your search

+7 -7
View File
@@ -87,7 +87,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}
private lazy var prefsController: PrefsWindowController = {
@MainActor private lazy var prefsController: PrefsWindowController = {
return PrefsWindowController()
}()
@@ -95,15 +95,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return Logger(fileURL: AppDelegate.appSupportURL().appendingPathComponent("debugLog.txt"))
}()
private lazy var activityWindowController: ActivityWindowController = {
@MainActor private lazy var activityWindowController: ActivityWindowController = {
return ActivityWindowController(logger: logger)
}()
private lazy var documentController: DocumentController = {
@MainActor private lazy var documentController: DocumentController = {
return DocumentController()
}()
private func runDonateAlert() {
@MainActor private func runDonateAlert() {
let defaults = UserDefaults.standard
let firstLaunch = defaults.bool(forKey: "SBFirstLaunch") ? false : true
@@ -276,17 +276,17 @@ extension AppDelegate {
}
}
@objc(queueItems) func queueItems() -> [QueueItem] {
@MainActor @objc(queueItems) func queueItems() -> [QueueItem] {
let queue = QueueController.shared
let indexes = IndexSet(integersIn: 0..<Int(queue.count))
return queue.items(at: indexes)
}
@objc(insertObject:inItemsAtIndex:) func insert(object: QueueItem, inItemsAtIndex index: UInt) {
@MainActor @objc(insertObject:inItemsAtIndex:) func insert(object: QueueItem, inItemsAtIndex index: UInt) {
QueueController.shared.insert(items: [object], at: IndexSet(integer: IndexSet.Element(index)))
}
@objc(removeObjectFromItemsAtIndex:) func removeObjectFromItemsAtIndex(_ index: UInt) {
@MainActor @objc(removeObjectFromItemsAtIndex:) func removeObjectFromItemsAtIndex(_ index: UInt) {
QueueController.shared.remove(at: IndexSet(integer: IndexSet.Element(index)))
}
+2 -6
View File
@@ -25,7 +25,8 @@ final class ArtworkSelectorViewItemLabel : NSTextField {
}
deinit {
removeObservers()
NotificationCenter.default.removeObserver(self, name: NSWindow.didBecomeKeyNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: NSWindow.didResignKeyNotification, object: nil)
}
private func addObservers() {
@@ -33,11 +34,6 @@ final class ArtworkSelectorViewItemLabel : NSTextField {
NotificationCenter.default.addObserver(self, selector: #selector(windowDidBecomeKey), name: NSWindow.didResignKeyNotification, object: window)
}
private func removeObservers() {
NotificationCenter.default.removeObserver(self, name: NSWindow.didBecomeKeyNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: NSWindow.didResignKeyNotification, object: nil)
}
@objc func windowDidBecomeKey() {
needsDisplay = true
}
+6 -6
View File
@@ -60,12 +60,12 @@ final class ChapterSearchController: ViewController, NSTableViewDataSource, NSTa
fatalError("init(coder:) has not been implemented")
}
deinit {
resultsTable.delegate = nil
resultsTable.dataSource = nil
chapterTable.delegate = nil
chapterTable.dataSource = nil
}
// deinit {
// resultsTable.delegate = nil
// resultsTable.dataSource = nil
// chapterTable.delegate = nil
// chapterTable.dataSource = nil
// }
override var nibName: NSNib.Name? {
return "SBChapterSearch"
+4 -4
View File
@@ -8,10 +8,10 @@
import Cocoa
@objc protocol ExpandedTableViewDelegate: NSTableViewDelegate {
@objc optional func deleteSelection(in tableview: NSTableView)
@objc optional func copySelection(in tableview: NSTableView)
@objc optional func cutSelection(in tableview: NSTableView)
@objc optional func paste(to tableview: NSTableView)
@MainActor @objc optional func deleteSelection(in tableview: NSTableView)
@MainActor @objc optional func copySelection(in tableview: NSTableView)
@MainActor @objc optional func cutSelection(in tableview: NSTableView)
@MainActor @objc optional func paste(to tableview: NSTableView)
}
class ExpandedTableView: NSTableView, NSMenuItemValidation {
+1 -1
View File
@@ -8,7 +8,7 @@
import Cocoa
protocol ItemViewDelegate: AnyObject {
func edit(item: QueueItem)
@MainActor func edit(item: QueueItem)
}
final class ItemViewController : NSViewController {
+7 -7
View File
@@ -94,13 +94,13 @@ final class MetadataSearchController: NSViewController, NSTableViewDataSource, N
fatalError("init(coder:) has not been implemented")
}
deinit {
resultsTable.delegate = nil
resultsTable.dataSource = nil
metadataTable.delegate = nil
metadataTable.dataSource = nil
}
// deinit {
// resultsTable.delegate = nil
// resultsTable.dataSource = nil
//
// metadataTable.delegate = nil
// metadataTable.dataSource = nil
// }
override var nibName: NSNib.Name? {
return "MetadataSearch"
@@ -117,10 +117,10 @@ final class MediaTagsController: NSViewController, NSTableViewDataSource, NSTabl
fatalError("init(coder:) has not been implemented")
}
deinit {
tableView.delegate = nil
tableView.dataSource = nil
}
// deinit {
// tableView.delegate = nil
// tableView.dataSource = nil
// }
override func viewDidLoad() {
super.viewDidLoad()
+4 -4
View File
@@ -9,7 +9,7 @@ import Foundation
@objc(SBQueueScriptCommand) class QueueScriptCommand: NSScriptCommand {
override func performDefaultImplementation() -> Any? {
@MainActor override func performDefaultImplementation() -> Any? {
guard let args = directParameter as? [URL] else { return nil }
QueueController.shared.insert(contentOf: args, at: QueueController.shared.count)
return nil
@@ -19,7 +19,7 @@ import Foundation
@objc(SBQueueStartAndWaitScriptCommand) class QueueStartAndWaitScriptCommand: NSScriptCommand {
override func performDefaultImplementation() -> Any? {
@MainActor override func performDefaultImplementation() -> Any? {
QueueController.shared.add(script: self)
QueueController.shared.start(self)
self.suspendExecution()
@@ -30,7 +30,7 @@ import Foundation
@objc(SBQueueStartScriptCommand) class QueueStartScriptCommand: NSScriptCommand {
override func performDefaultImplementation() -> Any? {
@MainActor override func performDefaultImplementation() -> Any? {
QueueController.shared.start(self)
return nil
}
@@ -39,7 +39,7 @@ import Foundation
@objc(SBQueueStopScriptCommand) class QueueStopScriptCommand: NSScriptCommand {
override func performDefaultImplementation() -> Any? {
@MainActor override func performDefaultImplementation() -> Any? {
QueueController.shared.stop(self)
return nil
}
+1 -1
View File
@@ -8,7 +8,7 @@
import Cocoa
protocol TokenChangeObserver: AnyObject {
func tokenDidChange(_ obj: Notification?)
@MainActor func tokenDidChange(_ obj: Notification?)
}
class TokenDelegate: NSObject, NSTokenFieldDelegate {
+2 -2
View File
@@ -9,8 +9,8 @@ import Cocoa
import MP42Foundation
protocol TracksViewControllerDelegate: AnyObject {
func didSelect(tracks: [MP42Track])
func delete(tracks: [MP42Track])
@MainActor func didSelect(tracks: [MP42Track])
@MainActor func delete(tracks: [MP42Track])
}
final class TracksViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate, ExpandedTableViewDelegate {
+4 -2
View File
@@ -1388,7 +1388,6 @@
buildSettings = {
ASSETCATALOG_COMPILER_OPTIMIZATION = space;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY = YES;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
@@ -1414,6 +1413,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
@@ -1466,6 +1466,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
RUN_CLANG_STATIC_ANALYZER = NO;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
};
name = Debug;
@@ -1475,7 +1476,6 @@
buildSettings = {
ASSETCATALOG_COMPILER_OPTIMIZATION = space;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY = YES;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
@@ -1501,6 +1501,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
@@ -1551,6 +1552,7 @@
RUN_CLANG_STATIC_ANALYZER = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
};
name = Release;