1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-11 04:28:58 +00:00

Corrects potential machine shutdown race condition.

This commit is contained in:
Thomas Harte 2019-03-02 23:17:31 -05:00
parent 113efd9b16
commit 05d483bc5b

View File

@ -199,23 +199,23 @@ class MachineDocument:
// MARK: CSOpenGLViewDelegate
final func openGLViewRedraw(_ view: CSOpenGLView, event redrawEvent: CSOpenGLViewRedrawEvent) {
if let machine = self.machine {
switch redrawEvent {
case .timer:
bestEffortLock.lock()
if let bestEffortUpdater = bestEffortUpdater {
bestEffortLock.unlock()
bestEffortUpdater.update()
} else {
bestEffortLock.unlock()
}
machine.updateView(forPixelSize: view.backingSize)
fallthrough
case .appKit:
machine.drawView(forPixelSize: view.backingSize)
if redrawEvent == .timer {
bestEffortLock.lock()
if let bestEffortUpdater = bestEffortUpdater {
bestEffortLock.unlock()
bestEffortUpdater.update()
} else {
bestEffortLock.unlock()
}
}
if drawLock.try() {
if redrawEvent == .timer {
machine.updateView(forPixelSize: view.backingSize)
}
machine.drawView(forPixelSize: view.backingSize)
drawLock.unlock()
}
}
// MARK: Runtime media insertion.