Skip to content

Commit

Permalink
Make sure always reload table on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
uiryuu authored and lhc70000 committed Feb 16, 2020
1 parent 2ecd779 commit f58f9a0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions iina/FilterWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ class FilterWindowController: NSWindowController, NSWindowDelegate {

// notifications
let notiName: Notification.Name = filterType == MPVProperty.af ? .iinaAFChanged : .iinaVFChanged
NotificationCenter.default.addObserver(self, selector: #selector(reloadTable), name: notiName, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadTable), name: .iinaMainWindowChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadTableInMainThread), name: notiName, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadTableInMainThread), name: .iinaMainWindowChanged, object: nil)
}

@objc
func reloadTableInMainThread() {
DispatchQueue.main.sync {
reloadTable()
}
}

func reloadTable() {
filters = PlayerCore.active.mpv.getFilters(filterType)
filterIsSaved = [Bool](repeatElement(false, count: filters.count))
Expand All @@ -89,10 +95,8 @@ class FilterWindowController: NSWindowController, NSWindowDelegate {
}
}
}
DispatchQueue.main.async {
self.currentFiltersTableView.reloadData()
self.savedFiltersTableView.reloadData()
}
currentFiltersTableView.reloadData()
savedFiltersTableView.reloadData()
}

func setFilters() {
Expand Down

0 comments on commit f58f9a0

Please sign in to comment.