mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Update isExecuting and isFinished in a way that should make NSOperationQueue happy. Hopefully this fixes a mystery crash bug.
This commit is contained in:
@@ -35,8 +35,7 @@ class FeedlyOperation: Operation {
|
||||
|
||||
downloadProgress = nil
|
||||
|
||||
isExecutingOperation = false
|
||||
isFinishedOperation = true
|
||||
updateExecutingAndFinished(false, true)
|
||||
}
|
||||
|
||||
func didFinish(_ error: Error) {
|
||||
@@ -58,9 +57,8 @@ class FeedlyOperation: Operation {
|
||||
|
||||
override func start() {
|
||||
guard !isCancelled else {
|
||||
isExecutingOperation = false
|
||||
isFinishedOperation = true
|
||||
|
||||
updateExecutingAndFinished(false, true)
|
||||
|
||||
if downloadProgress != nil {
|
||||
DispatchQueue.main.async {
|
||||
self.downloadProgress = nil
|
||||
@@ -69,8 +67,8 @@ class FeedlyOperation: Operation {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
isExecutingOperation = true
|
||||
|
||||
updateExecutingAndFinished(true, false)
|
||||
DispatchQueue.main.async {
|
||||
self.main()
|
||||
}
|
||||
@@ -80,24 +78,30 @@ class FeedlyOperation: Operation {
|
||||
return isExecutingOperation
|
||||
}
|
||||
|
||||
private var isExecutingOperation = false {
|
||||
willSet {
|
||||
willChangeValue(for: \.isExecuting)
|
||||
}
|
||||
didSet {
|
||||
didChangeValue(for: \.isExecuting)
|
||||
}
|
||||
}
|
||||
|
||||
override var isFinished: Bool {
|
||||
return isFinishedOperation
|
||||
}
|
||||
|
||||
private var isFinishedOperation = false {
|
||||
willSet {
|
||||
|
||||
private var isExecutingOperation = false
|
||||
private var isFinishedOperation = false
|
||||
|
||||
private func updateExecutingAndFinished(_ executing: Bool, _ finished: Bool) {
|
||||
let isExecutingDidChange = executing != isExecutingOperation
|
||||
let isFinishedDidChange = finished != isFinishedOperation
|
||||
|
||||
if isFinishedDidChange {
|
||||
willChangeValue(for: \.isFinished)
|
||||
}
|
||||
didSet {
|
||||
if isExecutingDidChange {
|
||||
willChangeValue(for: \.isExecuting)
|
||||
}
|
||||
isExecutingOperation = executing
|
||||
isFinishedOperation = finished
|
||||
|
||||
if isExecutingDidChange {
|
||||
didChangeValue(for: \.isExecuting)
|
||||
}
|
||||
if isFinishedDidChange {
|
||||
didChangeValue(for: \.isFinished)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user