From cb1c3211e9d08679752ab72e38661ccecd29d5f2 Mon Sep 17 00:00:00 2001 From: Joey Mezzacappa <20446836+jmezzacappa@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:10:49 -0400 Subject: [PATCH] Fix V86.destroy() with xterm.js (#720) `V86.destroy()` was throwing an error due to `SerialAdapterXtermJS` having no `destroy()` method. --- src/browser/serial.js | 7 ++++++- src/bus.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/browser/serial.js b/src/browser/serial.js index 2590674e..7c59050a 100644 --- a/src/browser/serial.js +++ b/src/browser/serial.js @@ -227,7 +227,7 @@ function SerialAdapterXtermJS(element, bus) term["setOption"]("logLevel", "off"); term.write("This is the serial console. Whatever you type or paste here will be sent to COM1"); - term["onData"](function(data) { + const on_data_disposable = term["onData"](function(data) { for(let i = 0; i < data.length; i++) { bus.send("serial0-input", data.charCodeAt(i)); @@ -238,6 +238,11 @@ function SerialAdapterXtermJS(element, bus) { term.write(chr); }, this); + + this.destroy = function() { + on_data_disposable["dispose"](); + term["dispose"](); + }; } SerialAdapterXtermJS.prototype.show = function() diff --git a/src/bus.js b/src/bus.js index 2846d255..e1ced8f5 100644 --- a/src/bus.js +++ b/src/bus.js @@ -33,7 +33,7 @@ BusConnector.prototype.register = function(name, fn, this_value) * Unregister one message with the given name and callback * * @param {string} name - * @param {function()} fn + * @param {function(?)} fn */ BusConnector.prototype.unregister = function(name, fn) {