Skip to content

Commit 3d19676

Browse files
committed
make gl3d, gl2d and mapbox .destroy() idempotent
- i.e. not crash when called multiple times
1 parent f758c35 commit 3d19676

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ proto.handleAnnotations = function() {
356356
};
357357

358358
proto.destroy = function() {
359+
if(!this.glplot) return;
360+
359361
var traces = this.traces;
360362

361363
if(traces) {

src/plots/gl3d/scene.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ proto.plot = function(sceneData, fullLayout, layout) {
593593
};
594594

595595
proto.destroy = function() {
596+
if(!this.glplot) return;
597+
596598
this.camera.mouseListener.enabled = false;
597599
this.container.removeEventListener('wheel', this.camera.wheelListener);
598600
this.camera = this.glplot.camera = null;

src/plots/mapbox/mapbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ proto.destroy = function() {
454454
if(this.map) {
455455
this.map.remove();
456456
this.map = null;
457+
this.container.removeChild(this.div);
457458
}
458-
this.container.removeChild(this.div);
459459
};
460460

461461
proto.toImage = function() {

0 commit comments

Comments
 (0)