From ec773abd68a9531d402770b17cfc47d9f22dbc00 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 10 Apr 2015 14:30:22 -0400 Subject: [PATCH] Fix crash when adding and removing a billboard before next update. As [reported on the forum](https://groups.google.com/d/msg/cesium-dev/Ti4jLsugBq4/13Qo5_daa68J), adding and then removing a billboard before the collection is updated causes a crash because we don't remove the billboards before trying to recreate the atlas. The new test I added fails in master but passes in this branch. --- Source/Scene/BillboardCollection.js | 3 ++- Specs/Scene/BillboardCollectionSpec.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Scene/BillboardCollection.js b/Source/Scene/BillboardCollection.js index bf87bb75e79c..9a1975acc216 100644 --- a/Source/Scene/BillboardCollection.js +++ b/Source/Scene/BillboardCollection.js @@ -1015,6 +1015,8 @@ define([ * @exception {RuntimeError} image with id must be in the atlas. */ BillboardCollection.prototype.update = function(context, frameState, commandList) { + removeBillboards(this); + var billboards = this._billboards; var billboardsLength = billboards.length; @@ -1036,7 +1038,6 @@ define([ return; } - removeBillboards(this); updateMode(this, frameState); billboards = this._billboards; diff --git a/Specs/Scene/BillboardCollectionSpec.js b/Specs/Scene/BillboardCollectionSpec.js index 9ec937ce6872..a9366ed83db0 100644 --- a/Specs/Scene/BillboardCollectionSpec.js +++ b/Specs/Scene/BillboardCollectionSpec.js @@ -122,6 +122,12 @@ defineSuite([ expect(b.id).not.toBeDefined(); }); + it('can add and remove before first update.', function() { + var b = billboards.add(); + billboards.remove(b); + billboards.update(context, frameState, []); + }); + it('explicitly constructs a billboard', function() { var b = billboards.add({ show : false,