Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes aspect related memory leaks #1418

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions ColumnSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,19 @@ define([
});

if (typeof this.expand === 'function') {
aspect.after(this, 'expand', function (promise, args) {
promise.then(function () {
var row = self.row(args[0]);
if (self._expanded[row.id]) {
// scrollLeft changes can't take effect on collapsed child rows;
// ensure they are properly updated once re-expanded.
adjustScrollLeft(self, row.element.connected);
}
});
return promise;
});
this._listeners.push(
aspect.after(this, 'expand', function (promise, args) {
promise.then(function () {
var row = self.row(args[0]);
if (self._expanded[row.id]) {
// scrollLeft changes can't take effect on collapsed child rows;
// ensure they are properly updated once re-expanded.
adjustScrollLeft(self, row.element.connected);
}
});
return promise;
})
);
}
},

Expand Down Expand Up @@ -273,8 +275,10 @@ define([
}
} else {
// first-time-only operations: hook up event/aspected handlers
aspect.after(this, 'resize', reposition, true);
aspect.after(this, 'styleColumn', reposition, true);
this._listeners.push(
aspect.after(this, 'resize', reposition, true),
aspect.after(this, 'styleColumn', reposition, true)
);
this._columnSetScrollerNode = domConstruct.create('div', {
className: 'dgrid-column-set-scroller-container'
}, this.footerNode, 'after');
Expand Down
27 changes: 16 additions & 11 deletions Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,20 @@ define([
// Initialize header now (since it's already been rendered),
// and aspect after future renderHeader calls to reset focus.
initHeader();
aspect.after(grid, 'renderHeader', initHeader, true);
grid._listeners.push(aspect.after(grid, 'renderHeader', initHeader, true));
}
else {
aspect.after(grid, 'renderArray', afterContentAdded, true);
aspect.after(grid, '_onNotification', function (rows, event) {
if (event.totalLength === 0) {
areaNode.tabIndex = 0;
}
else if (event.totalLength === 1 && event.type === 'add') {
afterContentAdded();
}
}, true);
grid._listeners.push(
aspect.after(grid, 'renderArray', afterContentAdded, true),
aspect.after(grid, '_onNotification', function (rows, event) {
if (event.totalLength === 0) {
areaNode.tabIndex = 0;
}
else if (event.totalLength === 1 && event.type === 'add') {
afterContentAdded();
}
}, true)
);
}

grid._listeners.push(on(areaNode, 'mousedown', function (event) {
Expand Down Expand Up @@ -295,8 +297,10 @@ define([

// Aspects may be about 10% slower than using an array-based appraoch,
// but there is significantly less code involved (here and above).
return aspect.after( // Handle
var handle = aspect.after( // Handle
this[isHeader ? 'headerKeyMap' : 'keyMap'], key, callback, true);
this._listeners.push(handle);
return handle;
},

_ensureRowScroll: function (rowElement) {
Expand Down Expand Up @@ -583,6 +587,7 @@ define([
handle.remove();
return rows;
});
this._listeners.push(handle);
}
};

Expand Down
8 changes: 5 additions & 3 deletions Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,11 @@ define([

// Update aspects if there is a collection change
if (this._setCollection) {
aspect.before(this, '_setCollection', function (collection) {
grid._updateDeselectionAspect(collection);
});
this._listeners.push(
aspect.before(this, '_setCollection', function (collection) {
grid._updateDeselectionAspect(collection);
})
);
}
this._updateDeselectionAspect();
},
Expand Down
9 changes: 8 additions & 1 deletion _StoreMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ define([
// The observer handle for the current collection, if trackable.
_observerHandle: null,

// _structureHandle: Object
// The observer handle for the configStructure aspect event.
_structureHandle: null,

// shouldTrackCollection: Boolean
// Whether this instance should track any trackable collection it is passed.
shouldTrackCollection: true,
Expand Down Expand Up @@ -84,14 +88,17 @@ define([
this._columnsWithSet = {};

// Reset _columnsWithSet whenever column configuration is reset
aspect.before(this, 'configStructure', lang.hitch(this, function () {
this._structureHandle = aspect.before(this, 'configStructure', lang.hitch(this, function () {
this._columnsWithSet = {};
}));
},

destroy: function () {
this.inherited(arguments);

if (this._structureHandle) {
this._structureHandle.remove();
}
if (this._renderedCollection) {
this._cleanupCollection();
}
Expand Down
12 changes: 7 additions & 5 deletions extensions/DnD.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,13 @@ define([
arrayUtil.forEach(event.rows, deselectRow);
});

aspect.after(this, 'destroy', function () {
delete this.dndSource._selectedNodes;
selectedNodes = null;
this.dndSource.destroy();
}, true);
this._listeners.push(
aspect.after(this, 'destroy', function () {
delete this.dndSource._selectedNodes;
selectedNodes = null;
this.dndSource.destroy();
}, true)
);
},

insertRow: function (object) {
Expand Down