1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-03 15:29:45 +00:00

Smarter: just ensures any attached panels are closed at close().

This commit is contained in:
Thomas Harte 2020-11-13 19:09:30 -05:00
parent 4862ccc947
commit 5dbc87caf0

View File

@ -88,14 +88,30 @@ class MachineDocument:
}
override func close() {
// Close any dangling sheets.
//
// Be warned: in 11.0 at least, if there are any panels then posting the endSheet request
// will defer the close(), and close() will be called again at the end of that animation.
//
// So: MAKE SURE IT'S SAFE TO ENTER THIS FUNCTION TWICE. Hence the non-assumption here about
// any windows still existing.
if self.windowControllers.count > 0, let window = self.windowControllers[0].window {
for sheet in window.sheets {
window.endSheet(sheet)
}
}
// Stop the machine, if any.
machine?.stop()
// Dismiss panels.
activityPanel?.setIsVisible(false)
activityPanel = nil
optionsPanel?.setIsVisible(false)
optionsPanel = nil
// End the update cycle.
actionLock.lock()
drawLock.lock()
machine = nil
@ -103,6 +119,7 @@ class MachineDocument:
actionLock.unlock()
drawLock.unlock()
// Let the document controller do its thing.
super.close()
}
@ -364,8 +381,6 @@ class MachineDocument:
}
@IBAction func cancelCreateMachine(_ sender: NSButton?) {
self.windowControllers[0].window?.endSheet(self.machinePickerPanel!)
self.machinePicker = nil
close()
}
@ -395,7 +410,6 @@ class MachineDocument:
}
@IBAction func cancelRequestROMs(_ sender: NSButton?) {
self.windowControllers[0].window?.endSheet(self.romRequesterPanel!)
close()
}