File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
cocos/scripting/js-bindings/manual/extension Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -872,16 +872,19 @@ void __JSDownloaderDelegator::startDownload()
872
872
_downloader->onDataTaskSuccess = [this ](const cocos2d::network::DownloadTask& task,
873
873
std::vector<unsigned char >& data)
874
874
{
875
- Image img;
875
+ Image* img = new (std::nothrow) Image () ;
876
876
Texture2D *tex = nullptr ;
877
877
do
878
878
{
879
- if (false == img. initWithImageData (data.data (), data.size ()))
879
+ if (false == img-> initWithImageData (data.data (), data.size ()))
880
880
{
881
881
break ;
882
882
}
883
- tex = Director::getInstance ()->getTextureCache ()->addImage (& img, _url);
883
+ tex = Director::getInstance ()->getTextureCache ()->addImage (img, _url);
884
884
} while (0 );
885
+
886
+ CC_SAFE_RELEASE (img);
887
+
885
888
if (tex)
886
889
{
887
890
this ->onSuccess (tex);
You can’t perform that action at this time.
0 commit comments