Merge pull request #2068 from jareguo/v1.7

fix potential memory leak when node detached from parent without cleanup
This commit is contained in:
Jare Guo
2017-10-25 08:06:06 -05:00
committed by GitHub
+15 -7
View File
@@ -27,15 +27,23 @@
var SceneGraphUtils = {
removeSgNode: function () {
var node = this._sgNode;
if (node) {
var parent = node._parent;
var sgNode = this._sgNode;
if (sgNode) {
var parent = sgNode._parent;
if (parent) {
parent.removeChild(node);
parent.removeChild(sgNode);
}
node.release();
if (this._sgNode._entity) {
this._sgNode._entity = null;
else {
// cleanup was skipped when its node was detaching
if (CC_JSB) {
sgNode.cleanup();
}
else {
sgNode.performRecursive(_ccsg.Node.performType.cleanup);
}
}
if (sgNode._entity) {
sgNode._entity = null;
}
}
},