Skip to content

Commit 31ea77b

Browse files
committed
Make destroySkin idempotent
1 parent ba712fd commit 31ea77b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/RenderWebGL.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,16 @@ class RenderWebGL extends EventEmitter {
690690
*/
691691
destroySkin (skinId) {
692692
const oldSkin = this._allSkins[skinId];
693+
/*
694+
Destroying a skin that is already gone is a no-op, not an error.
695+
696+
`costumeSync.syncRemoteToLocal` destroys every skin a rebuilt costume list no longer
697+
references, and a costume converting between vector and bitmap can have taken one already.
698+
Throwing there did far more than log: it abandoned the rest of the rebuild, so the costumes
699+
after the failure kept whatever pictures they had, with nothing to say the list was only
700+
half applied.
701+
*/
702+
if (!oldSkin) return;
693703
oldSkin.dispose();
694704
delete this._allSkins[skinId];
695705
}

0 commit comments

Comments
 (0)