Make V86Starter work when all loads are synchronous

This commit is contained in:
copy 2015-04-17 23:56:11 +02:00
parent 59440d8f34
commit 311c87e010

View file

@ -309,13 +309,11 @@ function V86Starter(options)
var starter = this; var starter = this;
var total = files_to_load.length; var total = files_to_load.length;
cont(0); var cont = function(index)
function cont(index)
{ {
if(index === total) if(index === total)
{ {
setTimeout(done, 0); setTimeout(done.bind(this), 0);
return; return;
} }
@ -333,7 +331,7 @@ function V86Starter(options)
else else
{ {
v86util.load_file(f.url, { v86util.load_file(f.url, {
done: function done(result) done: function(result)
{ {
put_on_settings(f.name, new SyncBuffer(result)); put_on_settings(f.name, new SyncBuffer(result));
cont(index + 1); cont(index + 1);
@ -353,9 +351,10 @@ function V86Starter(options)
as_text: f.as_text, as_text: f.as_text,
}); });
} }
} }.bind(this);
cont(0);
var done = function done() function done()
{ {
this.bus.send("cpu-init", settings); this.bus.send("cpu-init", settings);
@ -379,7 +378,7 @@ function V86Starter(options)
} }
}.bind(this), 0) }.bind(this), 0)
}.bind(this), 0); }.bind(this), 0);
}.bind(this); }
} }
/** /**