From e3291b515d7509fa5adab0c233657e64f21cf4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pasteau?= <4895034+ClementPasteau@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:55:58 +0100 Subject: [PATCH] Check existence of elements before destroying (#5913) Do not show in changelog --- newIDE/app/src/InstancesEditor/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/newIDE/app/src/InstancesEditor/index.js b/newIDE/app/src/InstancesEditor/index.js index 21b120d0a9..1eaa7f0f47 100644 --- a/newIDE/app/src/InstancesEditor/index.js +++ b/newIDE/app/src/InstancesEditor/index.js @@ -484,6 +484,8 @@ export default class InstancesEditor extends Component { // to protect against renders after the component is unmounted. this._unmounted = true; + // We've seen all those elements being undefined in some cases, so + // by security, check that they are defined before deleting them. if (this.selectionRectangle) { this.selectionRectangle.delete(); } @@ -501,8 +503,12 @@ export default class InstancesEditor extends Component { } if (this.nextFrame) cancelAnimationFrame(this.nextFrame); stopPIXITicker(); - this.pixiContainer.destroy(); - this.pixiRenderer.destroy(); + if (this.pixiContainer) { + this.pixiContainer.destroy(); + } + if (this.pixiRenderer) { + this.pixiRenderer.destroy(); + } } // To be updated, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops.