Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when adding/removing a path entity without rendering #3738

Merged
merged 2 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Change Log
* Fixed issue where `Camera.computeViewRectangle` was incorrect when crossing the international date line [#3717](https://github.com/AnalyticalGraphicsInc/cesium/issues/3717)
* Added `Rectangle` result parameter to `Camera.computeViewRectangle`
* Fix bug when upsampling exaggerated terrain where the terrain heights were exaggerated at twice the value. [#3607](https://github.com/AnalyticalGraphicsInc/cesium/issues/3607)
* Fixed a crash that would occur if you added and removed an `Entity` with a path without ever actually rendering it. [#3738](https://github.com/AnalyticalGraphicsInc/cesium/pull/3738)

### 1.19 - 2016-03-01

Expand Down
4 changes: 3 additions & 1 deletion Source/DataSources/PathVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ define([
entity = removed[i];
item = items.get(entity.id);
if (defined(item)) {
item.updater.removeObject(item);
if (defined(item.updater)) {
item.updater.removeObject(item);
}
items.remove(entity.id);
}
}
Expand Down
19 changes: 19 additions & 0 deletions Specs/DataSources/PathVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ defineSuite([
expect(scene.primitives.length).toEqual(0);
});

it('adding and removing an entity path without rendering does not crash.', function() {
var times = [new JulianDate(0, 0), new JulianDate(1, 0)];
var positions = [new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)];

var entityCollection = new EntityCollection();
visualizer = new PathVisualizer(scene, entityCollection);

var position = new SampledPositionProperty();
position.addSamples(times, positions);

var testObject = entityCollection.getOrCreateEntity('test');
testObject.position = position;
testObject.path = new PathGraphics();

//Before we fixed the issue, the below remove call would cause a crash
//when visualizer.update was not called at least once after the entity was added.
entityCollection.remove(testObject);
});

it('A PathGraphics causes a primitive to be created and updated.', function() {
var times = [new JulianDate(0, 0), new JulianDate(1, 0)];
var updateTime = new JulianDate(0.5, 0);
Expand Down