mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Improve cleanup on clone disposal
The `dispose()` method on `RenderedTarget` now: - informs the runtime that it should end any threads corresponding the target being disposed, and - removes the clone from its sprite.
This commit is contained in:
parent
d41997b58b
commit
454082b569
2 changed files with 14 additions and 0 deletions
|
@ -832,6 +832,8 @@ class RenderedTarget extends Target {
|
|||
*/
|
||||
dispose () {
|
||||
this.runtime.changeCloneCounter(-1);
|
||||
this.runtime.stopForTarget(this);
|
||||
this.sprite.removeClone(this);
|
||||
if (this.renderer && this.drawableID !== null) {
|
||||
this.renderer.destroyDrawable(this.drawableID);
|
||||
if (this.visible) {
|
||||
|
|
|
@ -58,6 +58,18 @@ class Sprite {
|
|||
}
|
||||
return newClone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect a clone from this sprite. The clone is unmodified.
|
||||
* In particular, the clone's dispose() method is not called.
|
||||
* @param {!RenderedTarget} clone - the clone to be removed.
|
||||
*/
|
||||
removeClone (clone) {
|
||||
const cloneIndex = this.clones.indexOf(clone);
|
||||
if (cloneIndex >= 0) {
|
||||
this.clones.splice(cloneIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Sprite;
|
||||
|
|
Loading…
Reference in a new issue