mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-21 10:49:50 -04:00
Merge pull request #1341 from mzgoddard/fix-report
fix unnecessary stackClick report from nested promise reporters
This commit is contained in:
commit
c428e2ec02
1 changed files with 7 additions and 7 deletions
|
@ -50,7 +50,7 @@ const isPromise = function (value) {
|
||||||
*/
|
*/
|
||||||
// @todo move this to callback attached to the thread when we have performance
|
// @todo move this to callback attached to the thread when we have performance
|
||||||
// metrics (dd)
|
// metrics (dd)
|
||||||
const handleReport = function (resolvedValue, sequencer, thread, blockCached) {
|
const handleReport = function (resolvedValue, sequencer, thread, blockCached, lastOperation) {
|
||||||
const currentBlockId = blockCached.id;
|
const currentBlockId = blockCached.id;
|
||||||
const opcode = blockCached.opcode;
|
const opcode = blockCached.opcode;
|
||||||
const isHat = blockCached._isHat;
|
const isHat = blockCached._isHat;
|
||||||
|
@ -80,7 +80,7 @@ const handleReport = function (resolvedValue, sequencer, thread, blockCached) {
|
||||||
} else {
|
} else {
|
||||||
// In a non-hat, report the value visually if necessary if
|
// In a non-hat, report the value visually if necessary if
|
||||||
// at the top of the thread stack.
|
// at the top of the thread stack.
|
||||||
if (typeof resolvedValue !== 'undefined' && thread.atStackTop()) {
|
if (lastOperation && typeof resolvedValue !== 'undefined' && thread.atStackTop()) {
|
||||||
if (thread.stackClick) {
|
if (thread.stackClick) {
|
||||||
sequencer.runtime.visualReport(currentBlockId, resolvedValue);
|
sequencer.runtime.visualReport(currentBlockId, resolvedValue);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ const handlePromise = (primitiveReportedValue, sequencer, thread, blockCached, l
|
||||||
}
|
}
|
||||||
// Promise handlers
|
// Promise handlers
|
||||||
primitiveReportedValue.then(resolvedValue => {
|
primitiveReportedValue.then(resolvedValue => {
|
||||||
handleReport(resolvedValue, sequencer, thread, blockCached);
|
handleReport(resolvedValue, sequencer, thread, blockCached, lastOperation);
|
||||||
// If its a command block.
|
// If its a command block.
|
||||||
if (lastOperation && typeof resolvedValue === 'undefined') {
|
if (lastOperation && typeof resolvedValue === 'undefined') {
|
||||||
let stackFrame;
|
let stackFrame;
|
||||||
|
@ -465,7 +465,7 @@ const execute = function (sequencer, thread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < length; i++) {
|
for (; i < length; i++) {
|
||||||
const last = i === length - 1;
|
const lastOperation = i === length - 1;
|
||||||
const opCached = ops[i];
|
const opCached = ops[i];
|
||||||
|
|
||||||
const blockFunction = opCached._blockFunction;
|
const blockFunction = opCached._blockFunction;
|
||||||
|
@ -501,7 +501,7 @@ const execute = function (sequencer, thread) {
|
||||||
|
|
||||||
// If it's a promise, wait until promise resolves.
|
// If it's a promise, wait until promise resolves.
|
||||||
if (isPromise(primitiveReportedValue)) {
|
if (isPromise(primitiveReportedValue)) {
|
||||||
handlePromise(primitiveReportedValue, sequencer, thread, opCached, last);
|
handlePromise(primitiveReportedValue, sequencer, thread, opCached, lastOperation);
|
||||||
|
|
||||||
// Store the already reported values. They will be thawed into the
|
// Store the already reported values. They will be thawed into the
|
||||||
// future versions of the same operations by block id. The reporting
|
// future versions of the same operations by block id. The reporting
|
||||||
|
@ -529,7 +529,7 @@ const execute = function (sequencer, thread) {
|
||||||
// and continue them later after thawing the reported values.
|
// and continue them later after thawing the reported values.
|
||||||
break;
|
break;
|
||||||
} else if (thread.status === Thread.STATUS_RUNNING) {
|
} else if (thread.status === Thread.STATUS_RUNNING) {
|
||||||
if (last) {
|
if (lastOperation) {
|
||||||
if (typeof primitiveReportedValue === 'undefined') {
|
if (typeof primitiveReportedValue === 'undefined') {
|
||||||
// No value reported - potentially a command block.
|
// No value reported - potentially a command block.
|
||||||
// Edge-activated hats don't request a glow; all
|
// Edge-activated hats don't request a glow; all
|
||||||
|
@ -537,7 +537,7 @@ const execute = function (sequencer, thread) {
|
||||||
thread.requestScriptGlowInFrame = true;
|
thread.requestScriptGlowInFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleReport(primitiveReportedValue, sequencer, thread, opCached);
|
handleReport(primitiveReportedValue, sequencer, thread, opCached, lastOperation);
|
||||||
} else {
|
} else {
|
||||||
// By definition a block that is not last in the list has a
|
// By definition a block that is not last in the list has a
|
||||||
// parent.
|
// parent.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue