From 995cd0b8e13f1845d10fce0f5b3d478a1e885029 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 22 Feb 2016 11:21:08 +0800 Subject: [PATCH] minor fix --- cocos2d/core/CCNode.js | 3 +++ cocos2d/core/components/CCComponent.js | 8 ++++++-- cocos2d/core/components/CCWidget.js | 2 +- cocos2d/core/utils/base-node.js | 4 ---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 9cc39ec28b..5459924b23 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -776,6 +776,9 @@ var Node = cc.Class({ // attach to prefab _Scene.PrefabUtils.linkPrefab(newPrefabRoot._prefab.asset, newPrefabRoot, this); } + + // conflict detection + _Scene.DetectConflict.afterAddChild(this); } }, diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index a56d93efaf..6922f94e4f 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -564,7 +564,9 @@ var Component = cc.Class({ callOnLostFocusInTryCatch(this); } } - _Scene.AssetsWatcher.start(this); + if ( !CC_TEST ) { + _Scene.AssetsWatcher.start(this); + } } if (this._enabled) { @@ -604,7 +606,9 @@ var Component = cc.Class({ // onDestroy if (CC_EDITOR) { - _Scene.AssetsWatcher.stop(this); + if ( !CC_TEST ) { + _Scene.AssetsWatcher.stop(this); + } if (cc.engine._isPlaying || this.constructor._executeInEditMode) { if (this.onDestroy) { callOnDestroyInTryCatch(this); diff --git a/cocos2d/core/components/CCWidget.js b/cocos2d/core/components/CCWidget.js index 34ee6f72cb..46f0be7773 100644 --- a/cocos2d/core/components/CCWidget.js +++ b/cocos2d/core/components/CCWidget.js @@ -410,7 +410,7 @@ var Widget = cc.Class({ } } - if (CC_EDITOR && !cc.engine._isPlaying) { + if (CC_EDITOR && !cc.engine._isPlaying && this.node._parent) { // adjust the offsets to keep the size and position unchanged after alignment chagned var type; if (flag & TOP) { diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index ac624e8b50..55777ae36b 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -147,10 +147,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ oldParent._children.splice(removeAt, 1); oldParent.emit(CHILD_REMOVED, this); this._onHierarchyChanged(oldParent); - - if (CC_EDITOR) { - _Scene.DetectConflict.afterAddChild(this); - } } } else if (value) {