mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Merge pull request #1511 from sapics/free-memory2
Release memory on Color
This commit is contained in:
commit
e057f20f37
2 changed files with 15 additions and 1 deletions
|
@ -2662,6 +2662,8 @@ new function() { // Injection scope for hit-test functions shared with project
|
||||||
var owner = this._getOwner(),
|
var owner = this._getOwner(),
|
||||||
project = this._project,
|
project = this._project,
|
||||||
index = this._index;
|
index = this._index;
|
||||||
|
if (this._style)
|
||||||
|
this._style._dispose();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
// Handle named children separately from index:
|
// Handle named children separately from index:
|
||||||
if (this._name)
|
if (this._name)
|
||||||
|
|
|
@ -174,8 +174,10 @@ var Style = Base.extend(new function() {
|
||||||
if (isColor) {
|
if (isColor) {
|
||||||
// The old value may be a native string or other color
|
// The old value may be a native string or other color
|
||||||
// description that wasn't coerced to a color object yet
|
// description that wasn't coerced to a color object yet
|
||||||
if (old && old._owner !== undefined)
|
if (old && old._owner !== undefined) {
|
||||||
old._owner = undefined;
|
old._owner = undefined;
|
||||||
|
old._canvasStyle = null;
|
||||||
|
}
|
||||||
if (value && value.constructor === Color) {
|
if (value && value.constructor === Color) {
|
||||||
// Clone color if it already has an owner.
|
// Clone color if it already has an owner.
|
||||||
// NOTE: If value is not a Color, it is only
|
// NOTE: If value is not a Color, it is only
|
||||||
|
@ -305,6 +307,16 @@ var Style = Base.extend(new function() {
|
||||||
|| false;
|
|| 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()
|
// DOCS: Style#hasFill()
|
||||||
hasFill: function() {
|
hasFill: function() {
|
||||||
var color = this.getFillColor();
|
var color = this.getFillColor();
|
||||||
|
|
Loading…
Reference in a new issue