mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 19:12:40 +08:00
Merge pull request #410 from pandamicro/master
Fix texture2d release issue
This commit is contained in:
@@ -14,19 +14,6 @@ var RawAsset = require('./CCRawAsset');
|
||||
cc.Asset = cc.Class({
|
||||
name: 'cc.Asset', extends: RawAsset,
|
||||
|
||||
ctor: function () {
|
||||
/**
|
||||
* @property _uuid
|
||||
* @type {String}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, '_uuid', {
|
||||
value: '',
|
||||
writable: true,
|
||||
enumerable: false // avoid uuid being assigned to empty string during destroy,
|
||||
});
|
||||
},
|
||||
|
||||
properties: {
|
||||
/**
|
||||
* Returns the url of this asset's first raw file, if none of rawFile exists,
|
||||
|
||||
@@ -12,6 +12,19 @@ var CCObject = require('../platform/CCObject');
|
||||
cc.RawAsset = cc.Class({
|
||||
name: 'cc.RawAsset', extends: CCObject,
|
||||
|
||||
ctor: function () {
|
||||
/**
|
||||
* @property _uuid
|
||||
* @type {String}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, '_uuid', {
|
||||
value: '',
|
||||
writable: true,
|
||||
enumerable: false // avoid uuid being assigned to empty string during destroy,
|
||||
});
|
||||
},
|
||||
|
||||
statics: {
|
||||
/**
|
||||
* Create a new node in the scene.
|
||||
|
||||
@@ -312,7 +312,7 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
|
||||
releaseTexture: function () {
|
||||
if (this._webTextureObj)
|
||||
cc._renderContext.deleteTexture(this._webTextureObj);
|
||||
cc.loader.release(this.url);
|
||||
cc.loader.release(this._uuid || this.url);
|
||||
},
|
||||
|
||||
getName: function () {
|
||||
|
||||
@@ -170,10 +170,13 @@ var textureCache = /** @lends cc.textureCache# */{
|
||||
* @example {@link utils/api/engine/docs/cocos2d/core/textures/removeTextureForKey.js}
|
||||
*/
|
||||
removeTextureForKey: function (textureKeyName) {
|
||||
if (textureKeyName == null)
|
||||
if (typeof textureKeyName !== 'string')
|
||||
return;
|
||||
if (this._textures[textureKeyName])
|
||||
delete(this._textures[textureKeyName]);
|
||||
var locTextures = this._textures;
|
||||
if (locTextures[textureKeyName]) {
|
||||
locTextures[textureKeyName].releaseTexture();
|
||||
delete(locTextures[textureKeyName]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user