From d20052cc22aacb129126e79ccff6a73cb3822475 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 4 Aug 2015 11:07:04 +0800 Subject: [PATCH 1/2] Fix line wrapper in CCDevice --- cocos/platform/mac/CCDevice-mac.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos/platform/mac/CCDevice-mac.mm b/cocos/platform/mac/CCDevice-mac.mm index 21c952f8d2..7614776d7c 100644 --- a/cocos/platform/mac/CCDevice-mac.mm +++ b/cocos/platform/mac/CCDevice-mac.mm @@ -39,8 +39,7 @@ int Device::getDPI() NSScreen *screen = [NSScreen mainScreen]; NSDictionary *description = [screen deviceDescription]; NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; - CGSize displayPhysicalSize = CGDisplayScreenSize( - [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); + CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); return ((displayPixelSize.width / displayPhysicalSize.width) * 25.4f); } From 37030a427cd1797119a14cf449944257f197a921 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 4 Aug 2015 12:45:49 +0800 Subject: [PATCH 2/2] Fix AssetsManager crash by protect Downloader with shared_ptr --- extensions/assets-manager/AssetsManagerEx.cpp | 2 +- extensions/assets-manager/Downloader.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/assets-manager/AssetsManagerEx.cpp b/extensions/assets-manager/AssetsManagerEx.cpp index 25fcdcb157..1af35b52c6 100644 --- a/extensions/assets-manager/AssetsManagerEx.cpp +++ b/extensions/assets-manager/AssetsManagerEx.cpp @@ -81,7 +81,7 @@ AssetsManagerEx::AssetsManagerEx(const std::string& manifestUrl, const std::stri _fileUtils = FileUtils::getInstance(); _updateState = State::UNCHECKED; - _downloader = std::make_shared(); + _downloader = std::shared_ptr(new Downloader); _downloader->setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); _downloader->_onError = std::bind(&AssetsManagerEx::onError, this, std::placeholders::_1); _downloader->_onProgress = std::bind(&AssetsManagerEx::onProgress, diff --git a/extensions/assets-manager/Downloader.cpp b/extensions/assets-manager/Downloader.cpp index 3187b19762..7025a32e5b 100644 --- a/extensions/assets-manager/Downloader.cpp +++ b/extensions/assets-manager/Downloader.cpp @@ -392,6 +392,7 @@ void Downloader::downloadToBufferSync(const std::string &srcUrl, unsigned char * void Downloader::downloadToBuffer(const std::string &srcUrl, const std::string &customId, const StreamData &buffer, const ProgressData &data) { std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); CURL *curl = curl_easy_init(); if (!curl) { @@ -463,6 +464,7 @@ void Downloader::downloadSync(const std::string &srcUrl, const std::string &stor void Downloader::download(const std::string &srcUrl, const std::string &customId, const FileDescriptor &fDesc, const ProgressData &data) { std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); CURL *curl = curl_easy_init(); if (!curl) { @@ -524,6 +526,7 @@ void Downloader::batchDownloadSync(const DownloadUnits &units, const std::string { // Make sure downloader won't be released std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); if (units.size() != 0) {