Skip to content

Commit

Permalink
Lily/Skins: fix delete all skins not deleting the renderer skins (#…
Browse files Browse the repository at this point in the history
…1718)

The code intended to delete the skins from the renderer when running the
"delete all skins" block, but since it tried to iterate through the
object like an array instead of iterating through the keys, it didn't
work.
This fixes a memory leak in the Skins extension.

(Also changes the `createdSkins` variable from an array into an object,
since it's used with string keys.)
  • Loading branch information
CST1229 authored Oct 11, 2024
1 parent d689cbc commit 363e5fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions extensions/Lily/Skins.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
const renderer = runtime.renderer;
const Cast = Scratch.Cast;

var createdSkins = [];
var createdSkins = {};

class Skins {
constructor() {
Expand Down Expand Up @@ -371,9 +371,9 @@

deleteAllSkins() {
this._refreshTargets();
for (let i = 0; i < createdSkins.length; i++)
renderer.destroySkin(createdSkins[i]);
createdSkins = [];
for (const skinName in createdSkins)
renderer.destroySkin(createdSkins[skinName]);
createdSkins = {};
}

restoreTargets(args) {
Expand Down

0 comments on commit 363e5fb

Please sign in to comment.