Skip to content

Commit 149472b

Browse files
authored
Fix a memory leak with the root column tree node (#994)
1 parent bb71932 commit 149472b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

addon/-private/column-tree.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ export default EmberObject.extend({
589589
this._super(...arguments);
590590

591591
this.token = new Token();
592+
this._root = null;
592593

593594
this._sortColumnsByFixed = this.sortColumnsByFixed.bind(this);
594595
this._ensureWidthConstraint = this.ensureWidthConstraint.bind(this);
@@ -599,7 +600,10 @@ export default EmberObject.extend({
599600

600601
destroy() {
601602
this.token.cancel();
602-
get(this, 'root').destroy();
603+
604+
if (this._root) {
605+
this._root.destroy();
606+
}
603607

604608
removeObserver(this, 'columns.@each.isFixed', this._sortColumnsByFixed);
605609
removeObserver(this, 'widthConstraint', this._ensureWidthConstraint);
@@ -608,9 +612,14 @@ export default EmberObject.extend({
608612
},
609613

610614
root: computed('columns', function() {
615+
if (this._root) {
616+
this._root.destroy();
617+
}
618+
611619
let columns = get(this, 'columns');
612620

613-
return ColumnTreeNode.create({ column: { subcolumns: columns }, tree: this });
621+
this._root = ColumnTreeNode.create({ column: { subcolumns: columns }, tree: this });
622+
return this._root;
614623
}),
615624

616625
rows: computed('root.{maxChildDepth,leaves.[]}', function() {

0 commit comments

Comments
 (0)