Fix V86.destroy() with xterm.js (#720)

`V86.destroy()` was throwing an error due to `SerialAdapterXtermJS`
having no `destroy()` method.
This commit is contained in:
Joey Mezzacappa 2022-08-15 16:10:49 -04:00 committed by GitHub
parent 62d967bce0
commit cb1c3211e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -227,7 +227,7 @@ function SerialAdapterXtermJS(element, bus)
term["setOption"]("logLevel", "off"); term["setOption"]("logLevel", "off");
term.write("This is the serial console. Whatever you type or paste here will be sent to COM1"); 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++) for(let i = 0; i < data.length; i++)
{ {
bus.send("serial0-input", data.charCodeAt(i)); bus.send("serial0-input", data.charCodeAt(i));
@ -238,6 +238,11 @@ function SerialAdapterXtermJS(element, bus)
{ {
term.write(chr); term.write(chr);
}, this); }, this);
this.destroy = function() {
on_data_disposable["dispose"]();
term["dispose"]();
};
} }
SerialAdapterXtermJS.prototype.show = function() SerialAdapterXtermJS.prototype.show = function()

View file

@ -33,7 +33,7 @@ BusConnector.prototype.register = function(name, fn, this_value)
* Unregister one message with the given name and callback * Unregister one message with the given name and callback
* *
* @param {string} name * @param {string} name
* @param {function()} fn * @param {function(?)} fn
*/ */
BusConnector.prototype.unregister = function(name, fn) BusConnector.prototype.unregister = function(name, fn)
{ {