Merge pull request #1511 from sapics/free-memory2

Release memory on Color
This commit is contained in:
sapics 2018-09-29 13:31:38 +09:00 committed by GitHub
commit e057f20f37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -2662,6 +2662,8 @@ new function() { // Injection scope for hit-test functions shared with project
var owner = this._getOwner(),
project = this._project,
index = this._index;
if (this._style)
this._style._dispose();
if (owner) {
// Handle named children separately from index:
if (this._name)

View file

@ -174,8 +174,10 @@ var Style = Base.extend(new function() {
if (isColor) {
// The old value may be a native string or other color
// description that wasn't coerced to a color object yet
if (old && old._owner !== undefined)
if (old && old._owner !== undefined) {
old._owner = undefined;
old._canvasStyle = null;
}
if (value && value.constructor === Color) {
// Clone color if it already has an owner.
// NOTE: If value is not a Color, it is only
@ -305,6 +307,16 @@ var Style = Base.extend(new function() {
|| false;
},
_dispose: function() {
var color;
color = this.getFillColor();
if (color) color._canvasStyle = null;
color = this.getStrokeColor();
if (color) color._canvasStyle = null;
color = this.getShadowColor();
if (color) color._canvasStyle = null;
},
// DOCS: Style#hasFill()
hasFill: function() {
var color = this.getFillColor();