Skip to content

Commit

Permalink
Merge pull request #13175 from PolygonalSun/adt-remove-obs
Browse files Browse the repository at this point in the history
ADT: Added check to attachToMesh to prevent potential memory leak
Former-commit-id: be4b508a7ca39d7875e1123d107c6954740a5c5a
  • Loading branch information
sebavan committed Oct 26, 2022
2 parents 00795ae + c697f45 commit 32b686d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/dev/gui/src/2D/advancedDynamicTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,11 @@ export class AdvancedDynamicTexture extends DynamicTexture {
if (!scene) {
return;
}

if (this._pointerObserver) {
scene.onPointerObservable.remove(this._pointerObserver);
}

this._pointerObserver = scene.onPointerObservable.add((pi) => {
if (
pi.type !== PointerEventTypes.POINTERMOVE &&
Expand Down

0 comments on commit 32b686d

Please sign in to comment.