Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix random ios crash reported by firebase.
  • Loading branch information
mpereyra committed May 5, 2021
1 parent 25ba2e5 commit a4c1473
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cocos/2d/CCRenderTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo
texture->release();
}
else
{
texture->release();
break;
}

_renderTargetFlags = RenderTargetFlag::COLOR;

Expand Down Expand Up @@ -475,10 +478,11 @@ void RenderTexture::newImage(std::function<void(Image*)> imageCallback, bool fli
int savedBufferWidth = (int)s.width;
int savedBufferHeight = (int)s.height;

bool hasPremultipliedAlpha = _texture2D->hasPremultipliedAlpha();
Image *image = new (std::nothrow) Image();
auto initCallback = [&, savedBufferWidth, savedBufferHeight, imageCallback](Image* image, const unsigned char* tempData){
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, _texture2D->hasPremultipliedAlpha());

auto initCallback = [savedBufferWidth, savedBufferHeight, hasPremultipliedAlpha, imageCallback](Image* image, const unsigned char* tempData){
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, hasPremultipliedAlpha);
imageCallback(image);
};
auto callback = std::bind(initCallback, image, std::placeholders::_1);
Expand Down

0 comments on commit a4c1473

Please sign in to comment.