Skip to content

Commit

Permalink
Fix crash when adding and removing a billboard before next update.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mramato committed Apr 10, 2015
1 parent b691b8a commit ec773ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/Scene/BillboardCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -1036,7 +1038,6 @@ define([
return;
}

removeBillboards(this);
updateMode(this, frameState);

billboards = this._billboards;
Expand Down
6 changes: 6 additions & 0 deletions Specs/Scene/BillboardCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ec773ab

Please sign in to comment.