Destroy emulator (fix #283)
This commit is contained in:
parent
833e9a2787
commit
9211c4fc87
33
examples/destroy.html
Normal file
33
examples/destroy.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!doctype html>
|
||||
<title>Destroyable Emulator</title>
|
||||
|
||||
<script src="../build/libv86.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
var emulator = new V86Starter({
|
||||
memory_size: 32 * 1024 * 1024,
|
||||
vga_memory_size: 2 * 1024 * 1024,
|
||||
screen_container: document.getElementById("screen_container"),
|
||||
bios: {
|
||||
url: "../bios/seabios.bin",
|
||||
},
|
||||
vga_bios: {
|
||||
url: "../bios/vgabios.bin",
|
||||
},
|
||||
cdrom: {
|
||||
url: "../images/linux.iso",
|
||||
},
|
||||
autostart: true,
|
||||
});
|
||||
|
||||
setTimeout(() => { emulator.destroy(); }, 1000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="screen_container">
|
||||
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
|
||||
<canvas style="display: none"></canvas>
|
||||
</div>
|
|
@ -459,7 +459,14 @@ V86Starter.prototype.stop = function()
|
|||
*/
|
||||
V86Starter.prototype.destroy = function()
|
||||
{
|
||||
this.keyboard_adapter.destroy();
|
||||
this.stop();
|
||||
|
||||
this.v86.destroy();
|
||||
this.keyboard_adapter && this.keyboard_adapter.destroy();
|
||||
this.network_adapter && this.network_adapter.destroy();
|
||||
this.mouse_adapter && this.mouse_adapter.destroy();
|
||||
this.screen_adapter && this.screen_adapter.destroy();
|
||||
this.serial_adapter && this.serial_adapter.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue