From 7e54a91ee6c791e0807ee38dca329935f54dfdb6 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 20 Oct 2015 16:28:03 +0800 Subject: [PATCH] Fix CCDownloader-curl will crash in js-test Fix broken image link in TextureCacheTest.js --- cocos/network/CCDownloader-curl.cpp | 4 +++- cocos/network/CCDownloader-curl.h | 1 + tests/js-tests/src/TextureCacheTest/TextureCacheTest.js | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cocos/network/CCDownloader-curl.cpp b/cocos/network/CCDownloader-curl.cpp index 60fc160daf..1f6320511d 100644 --- a/cocos/network/CCDownloader-curl.cpp +++ b/cocos/network/CCDownloader-curl.cpp @@ -698,6 +698,7 @@ namespace cocos2d { namespace network { DownloaderCURL::DownloaderCURL(const DownloaderHints& hints) : _impl(std::make_shared()) , _currTask(nullptr) + , _breakScheduleFunc(false) { DLLOG("Construct DownloaderCURL %p", this); _impl->hints = hints; @@ -731,6 +732,7 @@ namespace cocos2d { namespace network { DownloaderCURL::~DownloaderCURL() { + _breakScheduleFunc = true; _scheduler->unschedule(_schedulerKey, this); _scheduler->release(); @@ -845,7 +847,7 @@ namespace cocos2d { namespace network { DLLOG(" DownloaderCURL: finish Task: Id(%d)", coTask.serialId); } - if (_impl->stoped()) + if (!_breakScheduleFunc && _impl->stoped()) { _scheduler->pauseTarget(this); } diff --git a/cocos/network/CCDownloader-curl.h b/cocos/network/CCDownloader-curl.h index 6e877ba6a1..0475f46d7a 100644 --- a/cocos/network/CCDownloader-curl.h +++ b/cocos/network/CCDownloader-curl.h @@ -55,6 +55,7 @@ namespace cocos2d { namespace network void _onSchedule(float); std::string _schedulerKey; Scheduler* _scheduler; + bool _breakScheduleFunc; }; }} // namespace cocos2d::network diff --git a/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js index 6be071b43c..f77a0ef690 100644 --- a/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js +++ b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js @@ -79,9 +79,9 @@ var TextureLoadImgTest = TextureCacheTestBase.extend({ }); this.addChild(this._labelSecond, 1); - var url = "http://cn.cocos2d-x.org/image/logo.png"; + var url = "http://www.cocos2d-x.org/images/logo.png"; cc.textureCache.addImageAsync(url, this.texFirstLoaded, this); - cc.textureCache.addImageAsync(url, this.texSecondLoaded, this); + //cc.textureCache.addImageAsync(url, this.texSecondLoaded, this); }, texFirstLoaded: function(texture) { @@ -264,7 +264,7 @@ var TextureCacheTest = TextureCacheTestBase.extend({ var RemoteTextureTest = TextureCacheTestBase.extend({ _title:"Remote Texture Test", _subtitle:"", - _remoteTex: "http://cn.cocos2d-x.org/image/logo.png", + _remoteTex: "http://www.cocos2d-x.org/images/logo.png", onEnter:function () { this._super(); if('opengl' in cc.sys.capabilities && !cc.sys.isNative){ @@ -277,7 +277,7 @@ var RemoteTextureTest = TextureCacheTestBase.extend({ }, startDownload: function() { - var imageUrlArray = ["http://www.cocos2d-x.org/s/upload/v35.jpg", "http://www.cocos2d-x.org/s/upload/testin.jpg", "http://www.cocos2d-x.org/s/upload/geometry_dash.jpg", "http://cn.cocos2d-x.org/image/logo.png"]; + var imageUrlArray = ["http://www.cocos2d-x.org/s/upload/v35.jpg", "http://www.cocos2d-x.org/s/upload/testin.jpg", "http://www.cocos2d-x.org/s/upload/geometry_dash.jpg", "http://www.cocos2d-x.org/images/logo.png"]; for (var i = 0; i < imageUrlArray.length; i++) { cc.textureCache.addImageAsync(imageUrlArray[i], this.texLoaded, this);