fix(room): guard RoomPreviewer.updatePreviewModel against null _planeParser

After dispose() nulls out the internal _planeParser /
_backgroundSprite refs, any further updatePreviewModel call
crashed with 'this._planeParser is null'. React 19 StrictMode
in dev double-mounts effects (setup, cleanup, setup again),
which can briefly leave a consumer holding a stale reference
to a disposed previewer between the two setup runs. Bail
silently in that window instead of crashing the editor.
This commit is contained in:
simoleo89
2026-05-24 20:43:50 +02:00
committed by simoleo89
parent 28a41ba543
commit 2504aea85f
+6
View File
@@ -136,6 +136,12 @@ export class RoomPreviewer
public updatePreviewModel(model: string, wallHeight: number, scale: boolean = true): void public updatePreviewModel(model: string, wallHeight: number, scale: boolean = true): void
{ {
// Defensive: dispose() nulls _planeParser, and React 19
// StrictMode dev double-mount can leave a stale reference
// briefly pointing at a disposed instance. Bail rather
// than crashing with "cannot read property reset of null".
if(!this._planeParser) return;
const parser = new FloorHeightMapMessageParser(); const parser = new FloorHeightMapMessageParser();
parser.flush(); parser.flush();