Skip to content

Commit

Permalink
All Entity.parent to be set to undefined.
Browse files Browse the repository at this point in the history
This should have always worked, but we were missing a `defined` check.

Reported via the [forum](https://groups.google.com/d/msg/cesium-dev/danz-dtw8Jg/Id6DBZwaEQAJ)
  • Loading branch information
mramato committed Nov 5, 2015
1 parent 6c1a3a4 commit 4dd9b3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
* Fixed an issue where the sun texture is not generated correctly on some mobile devices. [#3141](https://github.com/AnalyticalGraphicsInc/cesium/issues/3141)
* Fixed a bug in the deprecated `jsonp` that prevented it from returning a promise. Its replacement, `loadJsonp`, was unaffected.
* 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.
* Fixed a bug that caused setting `Entity.parent` to `undefined` to throw an exception. [#3169](https://github.com/AnalyticalGraphicsInc/cesium/issues/3169)
* Added `Model.maximumScale` and `ModelGraphics.maximumScale` properties, giving an upper limit for minimumPixelSize.

### 1.15 - 2015-11-02
Expand Down
4 changes: 3 additions & 1 deletion Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ define([
}

this._parent = value;
value._children.push(this);
if (defined(value)) {
value._children.push(this);
}

var isShowing = this.isShowing;

Expand Down
17 changes: 17 additions & 0 deletions Specs/DataSources/EntitySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,21 @@ defineSuite([
expect(entity.show).toBe(true);
expect(entity.isShowing).toBe(false);
});

it('isShowing works when removing parent.', function() {
var entity = new Entity();
entity.parent = new Entity({
show : false
});
expect(entity.isShowing).toBe(false);

var listener = jasmine.createSpy('listener');
entity.definitionChanged.addEventListener(listener);

entity.parent = undefined;

expect(listener.calls.count()).toBe(2);
expect(listener.calls.argsFor(0)).toEqual([entity, 'isShowing', true, false]);
expect(entity.isShowing).toBe(true);
});
});

0 comments on commit 4dd9b3d

Please sign in to comment.