Fixed 'Clear All IO' button
This commit is contained in:
parent
0b2cb7e68c
commit
7a2517fd61
@ -262,6 +262,10 @@ class InputWaiter {
|
||||
|
||||
log.debug("Adding new InputWorker");
|
||||
this.inputWorker = new InputWorker();
|
||||
this.inputWorker.postMessage({
|
||||
action: "setLogLevel",
|
||||
data: log.getLevel()
|
||||
});
|
||||
this.inputWorker.postMessage({
|
||||
action: "updateMaxWorkers",
|
||||
data: this.maxWorkers
|
||||
@ -273,10 +277,7 @@ class InputWaiter {
|
||||
activeTab: this.manager.tabs.getActiveTab("input")
|
||||
}
|
||||
});
|
||||
this.inputWorker.postMessage({
|
||||
action: "setLogLevel",
|
||||
data: log.getLevel()
|
||||
});
|
||||
|
||||
this.inputWorker.addEventListener("message", this.handleInputWorkerMessage.bind(this));
|
||||
}
|
||||
|
||||
@ -1103,8 +1104,11 @@ class InputWaiter {
|
||||
this.manager.worker.setupChefWorker();
|
||||
this.addInput(true);
|
||||
|
||||
// Fire the statechange event as the input has been modified
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
// Fire the statechange event as the input has been modified,
|
||||
// leaving enough time for workers to be initialised
|
||||
setTimeout(function() {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}.bind(this), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -639,6 +639,7 @@ class OutputWaiter {
|
||||
async bufferToStr(buffer) {
|
||||
const encoding = this.getChrEnc();
|
||||
|
||||
if (buffer.byteLength === 0) return "";
|
||||
return await new Promise(resolve => {
|
||||
this.manager.worker.bufferToStr(buffer, encoding, r => {
|
||||
resolve(r.value);
|
||||
|
@ -326,30 +326,36 @@ class WorkerWaiter {
|
||||
* Cancels the current bake by terminating and removing all ChefWorkers
|
||||
*
|
||||
* @param {boolean} [silent=false] - If true, don't set the output
|
||||
* @param {boolean} killAll - If true, kills all chefWorkers regardless of status
|
||||
* @param {boolean} [killAll=false] - If true, kills all chefWorkers regardless of status
|
||||
*/
|
||||
cancelBake(silent, killAll) {
|
||||
cancelBake(silent=false, killAll=false) {
|
||||
const deactiveOutputs = new Set();
|
||||
|
||||
for (let i = this.chefWorkers.length - 1; i >= 0; i--) {
|
||||
if (this.chefWorkers[i].active || killAll) {
|
||||
const inputNum = this.chefWorkers[i].inputNum;
|
||||
this.removeChefWorker(this.chefWorkers[i]);
|
||||
this.manager.output.updateOutputStatus("inactive", inputNum);
|
||||
deactiveOutputs.add(inputNum);
|
||||
}
|
||||
}
|
||||
this.setBakingStatus(false);
|
||||
|
||||
for (let i = 0; i < this.inputs.length; i++) {
|
||||
this.manager.output.updateOutputStatus("inactive", this.inputs[i].inputNum);
|
||||
}
|
||||
this.inputs.forEach(input => {
|
||||
deactiveOutputs.add(input.inputNum);
|
||||
});
|
||||
|
||||
for (let i = 0; i < this.inputNums.length; i++) {
|
||||
this.manager.output.updateOutputStatus("inactive", this.inputNums[i]);
|
||||
}
|
||||
this.inputNums.forEach(inputNum => {
|
||||
deactiveOutputs.add(inputNum);
|
||||
});
|
||||
|
||||
deactiveOutputs.forEach(num => {
|
||||
this.manager.output.updateOutputStatus("inactive", num);
|
||||
});
|
||||
|
||||
const tabList = this.manager.tabs.getTabList("output");
|
||||
for (let i = 0; i < tabList.length; i++) {
|
||||
this.manager.tabs.getTabItem(tabList[i], "output").style.background = "";
|
||||
}
|
||||
tabList.forEach(tab => {
|
||||
this.manager.tabs.getTabItem(tab, "output").style.background = "";
|
||||
});
|
||||
|
||||
this.inputs = [];
|
||||
this.inputNums = [];
|
||||
@ -567,7 +573,7 @@ class WorkerWaiter {
|
||||
|
||||
return await new Promise(resolve => {
|
||||
if (this.app.baking) return;
|
||||
const inputNums = inputData.nums;
|
||||
const inputNums = inputData.nums.filter(n => n > 0);
|
||||
const step = inputData.step;
|
||||
|
||||
// Use cancelBake to clear out the inputs
|
||||
@ -610,6 +616,7 @@ class WorkerWaiter {
|
||||
});
|
||||
this.loadingOutputs++;
|
||||
}
|
||||
if (numBakes === 0) this.bakingComplete();
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user