Skip to content

Commit

Permalink
Ensure the RenderTexture reference is valid on threaded task completi…
Browse files Browse the repository at this point in the history
  • Loading branch information
rh101 authored Jul 11, 2024
1 parent 9e7a008 commit 7a5c45a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/2d/RenderTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
Expand Down

0 comments on commit 7a5c45a

Please sign in to comment.