Skip to content

Commit 3e989fa

Browse files
committed
🐛 Fix thread safety issues
1 parent fee96c8 commit 3e989fa

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Mac/View/NotesTableView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,14 @@ class NotesTableView: NSTableView, NSTableViewDataSource,
422422
}
423423

424424
func restoreScrollPosition() {
425-
guard let clipView = superview as? NSClipView else { return }
426-
let savedPosition = UserDefaultsManagement.notesTableScrollPosition
427-
if savedPosition > 0 {
428-
let newOrigin = NSPoint(x: clipView.bounds.origin.x, y: savedPosition)
429-
clipView.setBoundsOrigin(newOrigin)
425+
DispatchQueue.main.async { [weak self] in
426+
guard let self = self,
427+
let clipView = self.superview as? NSClipView else { return }
428+
let savedPosition = UserDefaultsManagement.notesTableScrollPosition
429+
if savedPosition > 0 {
430+
let newOrigin = NSPoint(x: clipView.bounds.origin.x, y: savedPosition)
431+
clipView.setBoundsOrigin(newOrigin)
432+
}
430433
}
431434
}
432435
}

0 commit comments

Comments
 (0)