diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 55777ae36b..006bf8fcad 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -124,6 +124,11 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ if (this._parent === value) { return; } + if (CC_EDITOR && !cc.engine.isPlaying) { + if (_Scene.DetectConflict.beforeAddChild(this)) { + return; + } + } var node = this._sgNode; if (node.parent) { node.parent.removeChild(node, false); diff --git a/test/qunit/unit/_init.js b/test/qunit/unit/_init.js index f616ac39ae..8ef440b5ca 100644 --- a/test/qunit/unit/_init.js +++ b/test/qunit/unit/_init.js @@ -107,7 +107,7 @@ var TestScript = cc.Class({ } }); -// polyfills to test engine extends +// mocks to test engine extends cc.engine = new (cc.Class({ extends: cc.EventTarget, @@ -121,6 +121,20 @@ cc.engine = new (cc.Class({ } }))(); +(function () { + function beFalse () { + return false; + } + + window._Scene = window._Scene || {}; + _Scene.DetectConflict = { + beforeAddChild: beFalse, + afterAddChild: beFalse, + checkConflict_Layout: beFalse, + checkConflict_Widget: beFalse, + }; +})(); + Editor.log = cc.log; Editor.warn = cc.warn; Editor.error = cc.error;