From 7a5c45a75b3c42c3165da286ed75b7f97f6897a2 Mon Sep 17 00:00:00 2001 From: RH Date: Thu, 11 Jul 2024 11:07:53 +1000 Subject: [PATCH] Ensure the RenderTexture reference is valid on threaded task completion (#2024) --- core/2d/RenderTexture.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } }); });