Skip to content

Commit 066e27b

Browse files
authored
Merge pull request #291 from vidartf/mem
Ensure we dispose wrapped objects when widget is destroyed
2 parents b922b30 + 2e229bb commit 066e27b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

js/src/_base/Three.js

+10
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ var ThreeModel = widgets.WidgetModel.extend({
191191

192192
this.on('change', this.onChange, this);
193193
this.on('msg:custom', this.onCustomMessage, this);
194+
this.on('destroy', this.onDestroy, this);
194195

195196
},
196197

@@ -247,6 +248,15 @@ var ThreeModel = widgets.WidgetModel.extend({
247248

248249
constructThreeObject: function() {},
249250

251+
onDestroy: function() {
252+
if (this.obj) {
253+
if (this.obj.dispose) {
254+
this.obj.dispose();
255+
}
256+
delete this.obj;
257+
}
258+
},
259+
250260

251261
//
252262
// Remote execution of three.js object methods

0 commit comments

Comments
 (0)