Skip to content

Commit

Permalink
Merge pull request #8591 from jony89/patch-1
Browse files Browse the repository at this point in the history
fix: memory leak event error is not unsubscribing
  • Loading branch information
mramato authored Apr 28, 2020
2 parents 44acf66 + 3ed3565 commit 55e2de9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Fixed an issue with clamping of non-looped glTF animations. Subscribers to animation `update` events should expect one additional event firing as an animation stops. [#7387](https://github.com/CesiumGS/cesium/issues/7387)
- Fixed a bug with very long view ranges requiring multiple frustums even with the logarithmic depth buffer enabled. Previously, such scenes could resolve depth incorrectly. [#8727](https://github.com/CesiumGS/cesium/pull/8727)
- Fixed a bug where the elevation contour material's alpha was not being applied. [#8749](https://github.com/CesiumGS/cesium/pull/8749)
- Fix potential memory leak when destroying `CesiumWidget` instances.

### 1.68.0 - 2020-04-01

Expand Down
10 changes: 7 additions & 3 deletions Source/Widgets/CesiumWidget/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,16 @@ function CesiumWidget(container, options) {
this.targetFrameRate = options.targetFrameRate;

var that = this;
scene.renderError.addEventListener(function (scene, error) {
this._onRenderError = function (scene, error) {
that._useDefaultRenderLoop = false;
that._renderLoopRunning = false;
if (that._showRenderLoopErrors) {
var title =
"An error occurred while rendering. Rendering has stopped.";
that.showErrorPanel(title, undefined, error);
}
});
};
scene.renderError.addEventListener(this._onRenderError);
} catch (error) {
if (showRenderLoopErrors) {
var title = "Error constructing CesiumWidget.";
Expand Down Expand Up @@ -709,7 +710,10 @@ CesiumWidget.prototype.isDestroyed = function () {
* removing the widget from layout.
*/
CesiumWidget.prototype.destroy = function () {
this._scene = this._scene && this._scene.destroy();
if (defined(this._scene)) {
this._scene.renderError.removeEventListener(this._onRenderError);
this._scene = this._scene.destroy();
}
this._container.removeChild(this._element);
this._creditContainer.removeChild(this._innerCreditContainer);
destroyObject(this);
Expand Down

0 comments on commit 55e2de9

Please sign in to comment.