From 34000f4bdead36350a687583e20aeeba5c571c92 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 6 Aug 2015 15:13:54 +0800 Subject: [PATCH 1/6] fix particle3d crash with error file --- .../WidgetReader/Particle3DReader/Particle3DReader.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp index 0332bf8e2e..84d814c781 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp @@ -147,14 +147,10 @@ namespace cocostudio auto fileData = options->fileData(); std::string path = fileData->path()->c_str(); - ParticleSystem3D* ret = NULL; - if(!FileUtils::getInstance()->isFileExist(path)) + PUParticleSystem3D* ret = PUParticleSystem3D::create(); + if (FileUtils::getInstance()->isFileExist(path)) { - ret = PUParticleSystem3D::create(); - } - else - { - ret = PUParticleSystem3D::create(path); + ret->initWithFilePath(path); } setPropsWithFlatBuffers(ret, particle3DOptions); From 8b2747c53bb3ad3eb663666b78d790b69178a64d Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 6 Aug 2015 18:03:50 +0800 Subject: [PATCH 2/6] fix particle3D file error --- extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp b/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp index 31f22e8c8f..4a28f4cd10 100644 --- a/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp +++ b/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp @@ -38,6 +38,8 @@ PUParticleSystem3DTranslator::~PUParticleSystem3DTranslator() void PUParticleSystem3DTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *node) { + if (typeid(*node) != typeid(PUObjectAbstractNode)) + return; PUObjectAbstractNode* obj = reinterpret_cast(node); if(obj->name.empty()) From 91c88ec535e5f6ffff47384c8a74ca768888b875 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 6 Aug 2015 18:12:08 +0800 Subject: [PATCH 3/6] Synchronize js parser with https://github.com/cocos2d/cocos2d-x/pull/13247 --- .../studio/parsers/timelineParser-2.x.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index b3c3dc6022..129852bf5b 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1519,10 +1519,12 @@ if(json["FileData"] && json["FileData"]["Path"]) resFile = resourcePath + json["FileData"]["Path"]; - var node; - if(resFile) - node = jsb.Sprite3D.create(resFile); - else + var node = null; + if(resFile) { + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.Sprite3D.create(resFile); + } + if(null === node) node = jsb.Sprite3D.create(); if(node) { @@ -1561,9 +1563,12 @@ if(json["FileData"] && json["FileData"]["Path"]) resFile = resourcePath+json["FileData"]["Path"]; - if(resFile) - node = jsb.PUParticleSystem3D.create(resFile); - else + if(resFile){ + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.PUParticleSystem3D.create(resFile); + } + + if(null === node) node = jsb.PUParticleSystem3D.create(); if(node){ From ca82f41c1b8e44cf7f52db2625454b78b88c7ad0 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Thu, 6 Aug 2015 19:03:26 +0800 Subject: [PATCH 4/6] Add loader tests --- tests/js-tests/src/LoaderTest/LoaderTest.js | 128 ++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/tests/js-tests/src/LoaderTest/LoaderTest.js b/tests/js-tests/src/LoaderTest/LoaderTest.js index 4893f2a823..f9b9d8d6ff 100644 --- a/tests/js-tests/src/LoaderTest/LoaderTest.js +++ b/tests/js-tests/src/LoaderTest/LoaderTest.js @@ -83,6 +83,134 @@ var LoaderTestLayer = BaseTestLayer.extend({ sprite.y = winSize.height/2; }); + }, + + onNextCallback: function(){ + var parent = this.getParent(); + parent.removeChild(this); + parent.addChild(new LoaderCycleLayer()); + } +}); + +var LoaderCycleLayer = BaseTestLayer.extend({ + _title:"Failed to load Test", + _subtitle:"", + + ctor: function(){ + BaseTestLayer.prototype.ctor.call(this); + var index = 0; + + var winSize = cc.director.getWinSize(); + var t = this, + cb = function(num){ + var labelTTF = new cc.LabelTTF(num + " file failed"); + labelTTF.x = index++*100 + winSize.width - 150; + labelTTF.y = winSize.height / 2 - 20; + if(num === 1) + labelTTF.setColor(cc.color.GREEN); + else + labelTTF.setColor(cc.color.RED); + t.addChild(labelTTF); + if(index < 4) + t.test(cb); + }; + this.createInfo(); + this.regLoad(); + this.test(cb); + }, + + regLoad: function(){ + cc.loader.register(["_test1"], { + load: function(realUrl, url, res, cb){ + cc.loader.cache[url] = {}; + setTimeout(function(){ + cb && cb(null, cc.loader.cache[url]); + return cc.loader.cache[url]; + }, Math.random()*1000); + + } + }); + cc.loader.register(["_test2"], { + load: function(realUrl, url, res, cb){ + cb && cb({}); + return null; + } + }); + }, + + list: [ + "1._test2", + "1._test1", + "2._test1", + "3._test1", + "4._test1" + ], + + createInfo: function(){ + var winSize = cc.director.getWinSize(); + var info1 = new cc.LabelTTF("Load 5 files"); + info1.x = winSize.width / 2; + info1.y = winSize.height / 2 + 80; + var info2 = new cc.LabelTTF("1 file does not exist"); + info2.x = winSize.width / 2; + info2.y = winSize.height / 2 + 60; + var info3 = new cc.LabelTTF("The other 4 files should be loaded."); + info3.x = winSize.width / 2; + info3.y = winSize.height / 2 + 40; + + this.addChild(info1); + this.addChild(info2); + this.addChild(info3); + + var info4 = new cc.LabelTTF("test 1"); + info4.x = winSize.width / 2 - 50; + info4.y = winSize.height / 2; + var info5 = new cc.LabelTTF("test 2"); + info5.x = winSize.width / 2 - 150; + info5.y = winSize.height / 2; + var info6 = new cc.LabelTTF("test 3"); + info6.x = winSize.width / 2 + 50; + info6.y = winSize.height / 2; + var info7 = new cc.LabelTTF("test 4"); + info7.x = winSize.width / 2 + 150; + info7.y = winSize.height / 2; + + this.addChild(info4); + this.addChild(info5); + this.addChild(info6); + this.addChild(info7); + }, + + test: function(cb){ + this.clearRes(); + var layer = this; + cc.loader.load(layer.list, function(){ + var num = 0; + layer.list.forEach(function(item){ + if(!cc.loader.getRes(item)){ + num++; + } + }); + cb(num); + }); + }, + + clearRes: function(){ + this.list.forEach(function(item){ + cc.loader.release(item); + }); + }, + + onRestartCallback: function(){ + var parent = this._parent; + parent.removeChild(this); + parent.addChild(new LoaderCycleLayer()); + }, + + onBackCallback: function(){ + var parent = this._parent; + parent.removeChild(this); + parent.addChild(new LoaderTestLayer()); } }); From 7b572bed9d37b09346270804d6d12c2d9c020d71 Mon Sep 17 00:00:00 2001 From: geron-cn Date: Thu, 6 Aug 2015 19:43:11 +0800 Subject: [PATCH 5/6] Fix crash when call removeChild from a bone which is already removed. --- cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp | 3 ++- web | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp index ad8aae028e..3ad40a41ce 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -116,7 +116,8 @@ void BoneNode::removeChild(Node* child, bool cleanup /* = true */) void BoneNode::removeFromBoneList(BoneNode* bone) { auto skeletonNode = dynamic_cast(bone); - if (skeletonNode == nullptr) // is not a nested skeleton + if (_rootSkeleton != nullptr && + skeletonNode == nullptr && bone->_rootSkeleton == _rootSkeleton) // is not a nested skeleton, and it is in skeleton tree { bone->_rootSkeleton = nullptr; auto subBones = bone->getAllSubBones(); diff --git a/web b/web index f26bb7a49e..0adcb2c24d 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit f26bb7a49e7ed37e43496c7edd0937a3c34a47d0 +Subproject commit 0adcb2c24daa76f112981b57a0105887d47a5c42 From eeb68b38b27669abb8fd70a0760afbd02257385d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 7 Aug 2015 15:03:54 +0800 Subject: [PATCH 6/6] Update web reference --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 0adcb2c24d..bb5c27ea4a 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 0adcb2c24daa76f112981b57a0105887d47a5c42 +Subproject commit bb5c27ea4a917e06d6ccab8031777657743f747f