CORPRIV-665: Protect NodeTerminalView from being destroyed twice.

This commit is contained in:
Chris Rankin 2017-02-09 17:14:49 +00:00
parent ccfbfde830
commit 975bba0295
2 changed files with 10 additions and 6 deletions

View File

@ -185,7 +185,7 @@ class NodeTabView : Fragment() {
if (config != null) { if (config != null) {
nodeConfigView.isVisible = false nodeConfigView.isVisible = false
nodeTab.text = config.legalName nodeTab.text = config.legalName
nodeTerminalView.open(config, onExit = { onTabClose(config) }) nodeTerminalView.open(config, onExit = { onTerminalExit(config) })
nodeTab.setOnSelectionChanged { nodeTab.setOnSelectionChanged {
if (nodeTab.isSelected) { if (nodeTab.isSelected) {
@ -196,7 +196,7 @@ class NodeTabView : Fragment() {
} }
} }
private fun onTabClose(config: NodeConfig) { private fun onTerminalExit(config: NodeConfig) {
Platform.runLater { Platform.runLater {
nodeTab.requestClose() nodeTab.requestClose()
nodeController.dispose(config) nodeController.dispose(config)

View File

@ -33,6 +33,7 @@ class NodeTerminalView : Fragment() {
private val viewDatabaseButton by fxid<Button>() private val viewDatabaseButton by fxid<Button>()
private val launchExplorerButton by fxid<Button>() private val launchExplorerButton by fxid<Button>()
private var isClosed: Boolean = false
private val explorer = explorerController.explorer() private val explorer = explorerController.explorer()
private val viewer = DBViewer() private val viewer = DBViewer()
private var rpc: NodeRPC? = null private var rpc: NodeRPC? = null
@ -114,10 +115,13 @@ class NodeTerminalView : Fragment() {
}) })
fun close() { fun close() {
explorer.close() if (!isClosed) {
viewer.close() explorer.close()
rpc?.close() viewer.close()
pty?.close() rpc?.close()
pty?.close()
isClosed = true
}
} }
fun refreshTerminal() { fun refreshTerminal() {