1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-30 01:37:19 +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 // MARK: CSOpenGLViewDelegate
final func openGLViewRedraw(_ view: CSOpenGLView, event redrawEvent: CSOpenGLViewRedrawEvent) { final func openGLViewRedraw(_ view: CSOpenGLView, event redrawEvent: CSOpenGLViewRedrawEvent) {
if let machine = self.machine { if redrawEvent == .timer {
switch redrawEvent { bestEffortLock.lock()
case .timer: if let bestEffortUpdater = bestEffortUpdater {
bestEffortLock.lock() bestEffortLock.unlock()
if let bestEffortUpdater = bestEffortUpdater { bestEffortUpdater.update()
bestEffortLock.unlock() } else {
bestEffortUpdater.update() bestEffortLock.unlock()
} else {
bestEffortLock.unlock()
}
machine.updateView(forPixelSize: view.backingSize)
fallthrough
case .appKit:
machine.drawView(forPixelSize: view.backingSize)
} }
} }
if drawLock.try() {
if redrawEvent == .timer {
machine.updateView(forPixelSize: view.backingSize)
}
machine.drawView(forPixelSize: view.backingSize)
drawLock.unlock()
}
} }
// MARK: Runtime media insertion. // MARK: Runtime media insertion.