From ffa47e3beb92aea00d7c36a1e64ea5a10ef2516d Mon Sep 17 00:00:00 2001 From: rropp5 <12055531+rropp5@users.noreply.github.com> Date: Tue, 21 Nov 2023 00:10:33 -0500 Subject: [PATCH] Remove destroyed PolylineCollection from Scene #7758 Remove PolylineCollections from the Scene before they are destroyed. This causes #7758 and #9154. --- .../Source/DataSources/PolylineGeometryUpdater.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/engine/Source/DataSources/PolylineGeometryUpdater.js b/packages/engine/Source/DataSources/PolylineGeometryUpdater.js index 6ad349c9d862..6c3a595a9aa5 100644 --- a/packages/engine/Source/DataSources/PolylineGeometryUpdater.js +++ b/packages/engine/Source/DataSources/PolylineGeometryUpdater.js @@ -874,6 +874,7 @@ DynamicGeometryUpdater.prototype.destroy = function () { if (defined(polylineCollection)) { polylineCollection.remove(this._line); if (polylineCollection.length === 0) { + removePolylineCollection(geometryUpdater._scene.primitives, polylineCollection); this._primitives.removeAndDestroy(polylineCollection); delete polylineCollections[sceneId]; } @@ -883,4 +884,16 @@ DynamicGeometryUpdater.prototype.destroy = function () { } destroyObject(this); }; + +function removePolylineCollection(primitiveCollection, toRemove) { + if (defined(primitiveCollection)) { + if (typeof primitiveCollection.remove === "function") { + primitiveCollection.remove(toRemove); + } + + for (let i = 0; i < primitiveCollection.length; i++) { + removePolylineCollection(primitiveCollection.get(i), toRemove); + } + } +}; export default PolylineGeometryUpdater;