mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Resolved deadlock if an invalidate call was sent to the Electron while it was in the middle of an update.
This commit is contained in:
parent
a01f90ff3e
commit
bbffbb5dc2
@ -55,21 +55,24 @@ class ElectronDocument: MachineDocument {
|
|||||||
electron.setROM(data, slot: 15)
|
electron.setROM(data, slot: 15)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lazy var actionLock = NSLock()
|
||||||
override func close() {
|
override func close() {
|
||||||
objc_sync_enter(self)
|
actionLock.lock()
|
||||||
electron.sync()
|
electron.sync()
|
||||||
openGLView.invalidate()
|
openGLView.invalidate()
|
||||||
openGLView.openGLContext!.makeCurrentContext()
|
openGLView.openGLContext!.makeCurrentContext()
|
||||||
electron = nil
|
electron = nil
|
||||||
|
actionLock.unlock()
|
||||||
|
|
||||||
super.close()
|
super.close()
|
||||||
objc_sync_exit(self)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: CSOpenGLViewDelegate
|
// MARK: CSOpenGLViewDelegate
|
||||||
override func runForNumberOfCycles(numberOfCycles: Int32) {
|
override func runForNumberOfCycles(numberOfCycles: Int32) {
|
||||||
objc_sync_enter(self)
|
if actionLock.tryLock() {
|
||||||
electron?.runForNumberOfCycles(numberOfCycles)
|
electron?.runForNumberOfCycles(numberOfCycles)
|
||||||
objc_sync_exit(self)
|
actionLock.unlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func openGLView(view: CSCathodeRayView, drawViewOnlyIfDirty onlyIfDirty: Bool) {
|
override func openGLView(view: CSCathodeRayView, drawViewOnlyIfDirty onlyIfDirty: Bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user