Skip to content

Commit

Permalink
Fix a memory leak with the root column tree node (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmun authored Jul 30, 2023
1 parent bb71932 commit 149472b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions addon/-private/column-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ export default EmberObject.extend({
this._super(...arguments);

this.token = new Token();
this._root = null;

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

destroy() {
this.token.cancel();
get(this, 'root').destroy();

if (this._root) {
this._root.destroy();
}

removeObserver(this, '[email protected]', this._sortColumnsByFixed);
removeObserver(this, 'widthConstraint', this._ensureWidthConstraint);
Expand All @@ -608,9 +612,14 @@ export default EmberObject.extend({
},

root: computed('columns', function() {
if (this._root) {
this._root.destroy();
}

let columns = get(this, 'columns');

return ColumnTreeNode.create({ column: { subcolumns: columns }, tree: this });
this._root = ColumnTreeNode.create({ column: { subcolumns: columns }, tree: this });
return this._root;
}),

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

0 comments on commit 149472b

Please sign in to comment.