From e9c4e8cf3b01e6eb51b56ad0313db2a195d962dd Mon Sep 17 00:00:00 2001 From: sapics Date: Fri, 21 Sep 2018 16:07:44 +0900 Subject: [PATCH] Release memory on Color --- src/item/Item.js | 2 ++ src/style/Style.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/item/Item.js b/src/item/Item.js index 6b8183f2..2b762f63 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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) diff --git a/src/style/Style.js b/src/style/Style.js index 1b2dccb2..f8e10280 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -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();