Fix a KVO crash.
This commit is contained in:
2 files changed
+6
-10
No files matched your search
@@ -42,10 +42,10 @@ import Cocoa
|
|||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
// Observe the item status
|
// Observe the item status
|
||||||
statusObserver = self.observe(\.item.status, options: [.initial, .new]) { [weak self] observed, change in
|
statusObserver = item.observe(\.status, options: [.initial, .new]) { [weak self] observed, change in
|
||||||
guard let s = self, let status = change.newValue else { return }
|
guard let s = self else { return }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if status != SBQueueItemStatus.ready && status != SBQueueItemStatus.editing {
|
if s.item.status != SBQueueItemStatus.ready && s.item.status != SBQueueItemStatus.editing {
|
||||||
s.editButton.isEnabled = false
|
s.editButton.isEnabled = false
|
||||||
} else {
|
} else {
|
||||||
s.editButton.isEnabled = true
|
s.editButton.isEnabled = true
|
||||||
@@ -54,9 +54,9 @@ import Cocoa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Observe the item actions
|
// Observe the item actions
|
||||||
actionsObserver = self.observe(\.item.actions, options: [.initial, .new]) { [weak self] observed, change in
|
actionsObserver = item.observe(\.actions, options: [.initial, .new, .old]) { [weak self] observed, change in
|
||||||
guard let s = self, let newCount = change.newValue?.count, let oldCount = change.oldValue?.count else { return }
|
guard let s = self, let newCount = change.newValue?.count else { return }
|
||||||
let count = newCount - oldCount
|
let count = newCount - (change.oldValue?.count ?? 0)
|
||||||
let height = 16.0 * CGFloat(count >= 0 ? count : 1)
|
let height = 16.0 * CGFloat(count >= 0 ? count : 1)
|
||||||
s.tableHeight.constant = height
|
s.tableHeight.constant = height
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,10 +431,6 @@ static void *SBQueueContex = &SBQueueContex;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPopoverSize:(NSSize)size {
|
|
||||||
self.itemPopover.contentSize = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)popoverShouldDetach:(NSPopover *)popover
|
- (BOOL)popoverShouldDetach:(NSPopover *)popover
|
||||||
{
|
{
|
||||||
if (popover == self.popover) {
|
if (popover == self.popover) {
|
||||||
|
|||||||
Reference in new issue
Block a user