diff options
author | Peter Nelson <peter@peterdn.com> | 2020-09-12 12:36:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-12 20:26:14 +0200 |
commit | 9494b03a020f603c0f2a372474fb6c0a5a8a8473 (patch) | |
tree | d08d857ada2c07c76ef806607b8260f591a40341 /Libraries/LibWeb/Loader/ImageResource.cpp | |
parent | 16ebbde26fd66da1e5a78ddd3a8b71d7df14eec7 (diff) | |
download | serenity-9494b03a020f603c0f2a372474fb6c0a5a8a8473.zip |
LibWeb: cache in-process decoded images in ImageResource
Otherwise cloned Bitmaps returned by the decoder will be prematurely
freed
Diffstat (limited to 'Libraries/LibWeb/Loader/ImageResource.cpp')
-rw-r--r-- | Libraries/LibWeb/Loader/ImageResource.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibWeb/Loader/ImageResource.cpp b/Libraries/LibWeb/Loader/ImageResource.cpp index e3e714cfce..3daa284deb 100644 --- a/Libraries/LibWeb/Loader/ImageResource.cpp +++ b/Libraries/LibWeb/Loader/ImageResource.cpp @@ -62,10 +62,10 @@ const Gfx::Bitmap* ImageResource::bitmap(size_t frame_index) const if (!m_decoder) return nullptr; if (m_decoder->is_animated()) - return m_decoder->frame(frame_index).image; - return m_decoder->bitmap(); - } - if (!m_decoded_image && !m_has_attempted_decode) { + m_decoded_image = m_decoder->frame(frame_index).image; + else + m_decoded_image = m_decoder->bitmap(); + } else if (!m_decoded_image && !m_has_attempted_decode) { auto image_decoder_client = ImageDecoderClient::Client::construct(); m_decoded_image = image_decoder_client->decode_image(encoded_data()); m_has_attempted_decode = true; |