Skip to content

Commit ee68e6b

Browse files
committed
Merge pull request #3169 from AnalyticalGraphicsInc/undefined-parent
All Entity.parent to be set to undefined.
2 parents bb288a0 + 4dd9b3d commit ee68e6b

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Change Log
66
* Fixed an issue where the sun texture is not generated correctly on some mobile devices. [#3141](https://github.com/AnalyticalGraphicsInc/cesium/issues/3141)
77
* Fixed a bug in the deprecated `jsonp` that prevented it from returning a promise. Its replacement, `loadJsonp`, was unaffected.
88
* Fixed glTF implementation to read the version as a string as per the specification and to correctly handle backwards compatibility for axis-angle rotations in glTF 0.8 models.
9+
* Fixed a bug that caused setting `Entity.parent` to `undefined` to throw an exception. [#3169](https://github.com/AnalyticalGraphicsInc/cesium/issues/3169)
910
* Added `Model.maximumScale` and `ModelGraphics.maximumScale` properties, giving an upper limit for minimumPixelSize.
1011
* Entities have a reference to their entity collection.
1112
* Entity collections have a reference to their owner (usually a data source, but can be a `CompositeEntityCollection`).

Source/DataSources/Entity.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ define([
303303
}
304304

305305
this._parent = value;
306-
value._children.push(this);
306+
if (defined(value)) {
307+
value._children.push(this);
308+
}
307309

308310
var isShowing = this.isShowing;
309311

Specs/DataSources/EntitySpec.js

+17
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,21 @@ defineSuite([
462462
expect(entity.show).toBe(true);
463463
expect(entity.isShowing).toBe(false);
464464
});
465+
466+
it('isShowing works when removing parent.', function() {
467+
var entity = new Entity();
468+
entity.parent = new Entity({
469+
show : false
470+
});
471+
expect(entity.isShowing).toBe(false);
472+
473+
var listener = jasmine.createSpy('listener');
474+
entity.definitionChanged.addEventListener(listener);
475+
476+
entity.parent = undefined;
477+
478+
expect(listener.calls.count()).toBe(2);
479+
expect(listener.calls.argsFor(0)).toEqual([entity, 'isShowing', true, false]);
480+
expect(entity.isShowing).toBe(true);
481+
});
465482
});

0 commit comments

Comments
 (0)