mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Return restarted threads in list from startHats
Add restarted threads to the list of newThreads returned by startHats.
This commit is contained in:
parent
9864403bc9
commit
3d92553459
1 changed files with 5 additions and 3 deletions
|
@ -804,6 +804,7 @@ class Runtime extends EventEmitter {
|
||||||
* This is used by `startHats` to and is necessary to ensure 2.0-like execution order.
|
* This is used by `startHats` to and is necessary to ensure 2.0-like execution order.
|
||||||
* Test project: https://scratch.mit.edu/projects/130183108/
|
* Test project: https://scratch.mit.edu/projects/130183108/
|
||||||
* @param {!Thread} thread Thread object to restart.
|
* @param {!Thread} thread Thread object to restart.
|
||||||
|
* @return {Thread} The restarted thread.
|
||||||
*/
|
*/
|
||||||
_restartThread (thread) {
|
_restartThread (thread) {
|
||||||
const newThread = new Thread(thread.topBlock);
|
const newThread = new Thread(thread.topBlock);
|
||||||
|
@ -814,9 +815,10 @@ class Runtime extends EventEmitter {
|
||||||
const i = this.threads.indexOf(thread);
|
const i = this.threads.indexOf(thread);
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
this.threads[i] = newThread;
|
this.threads[i] = newThread;
|
||||||
} else {
|
return newThread;
|
||||||
this.threads.push(thread);
|
|
||||||
}
|
}
|
||||||
|
this.threads.push(thread);
|
||||||
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -976,7 +978,7 @@ class Runtime extends EventEmitter {
|
||||||
if (instance.threads[i].topBlock === topBlockId &&
|
if (instance.threads[i].topBlock === topBlockId &&
|
||||||
!instance.threads[i].stackClick && // stack click threads and hat threads can coexist
|
!instance.threads[i].stackClick && // stack click threads and hat threads can coexist
|
||||||
instance.threads[i].target === target) {
|
instance.threads[i].target === target) {
|
||||||
instance._restartThread(instance.threads[i]);
|
newThreads.push(instance._restartThread(instance.threads[i]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue