1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Image: Update return type of getPixelData to avoid dangling pointers

This commit is contained in:
reuk 2024-12-03 19:41:43 +00:00
parent 0be5ad1afc
commit dcca72484f
9 changed files with 22 additions and 23 deletions

View file

@ -73,7 +73,7 @@ struct CachedImageList final : public ReferenceCountedObject,
TextureInfo getTextureFor (const Image& image)
{
auto pixelData = image.getPixelData();
auto* c = findCachedImage (pixelData);
auto* c = findCachedImage (pixelData.get());
if (c == nullptr)
{
@ -89,7 +89,7 @@ struct CachedImageList final : public ReferenceCountedObject,
return t;
}
c = images.add (new CachedImage (*this, pixelData));
c = images.add (new CachedImage (*this, pixelData.get()));
totalSize += c->imageSize;
while (totalSize > maxCacheSize && images.size() > 1 && totalSize > 0)

View file

@ -217,7 +217,7 @@ ImagePixelData::Ptr OpenGLImageType::create (Image::PixelFormat, int width, int
OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image)
{
if (OpenGLFrameBufferImage* const glImage = dynamic_cast<OpenGLFrameBufferImage*> (image.getPixelData()))
if (OpenGLFrameBufferImage* const glImage = dynamic_cast<OpenGLFrameBufferImage*> (image.getPixelData().get()))
return &(glImage->frameBuffer);
return nullptr;