diff --git a/core/2d/RenderTexture.cpp b/core/2d/RenderTexture.cpp index d6142ce621f2..8d0f6665622b 100644 --- a/core/2d/RenderTexture.cpp +++ b/core/2d/RenderTexture.cpp @@ -468,14 +468,14 @@ void RenderTexture::onSaveToFile(std::string filename, bool isRGBA, bool forceNo { if (forceNonPMA && image->hasPremultipliedAlpha()) { - _director->getJobSystem()->enqueue([this, image, _filename, isRGBA, forceNonPMA]() { + _director->getJobSystem()->enqueue([self = RefPtr(this), image, _filename, isRGBA, forceNonPMA]() { image->reversePremultipliedAlpha(); - Director::getInstance()->getScheduler()->runOnAxmolThread([this, image, _filename, isRGBA] { + Director::getInstance()->getScheduler()->runOnAxmolThread([self, image, _filename, isRGBA] { image->saveToFile(_filename, !isRGBA); - if (_saveFileCallback) + if (self->_saveFileCallback) { - _saveFileCallback(this, _filename); + self->_saveFileCallback(self, _filename); } }); });