vcl/source/filter/graphicfilter.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
New commits: commit 2da5506d1c2d9513a96de25f5782f706a108165f Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Apr 30 17:36:42 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Apr 30 13:21:23 2025 +0200 vcl: Fix threaded reading of graphics Make the behavior of handling errors the same as with readPNG (ignore the returned bool result, but check if the bitmap is set and not empty). Also make sure we always create the Graphic, even if there was a read error, so the check to be loaded and loaded graphics passes: assert(loadedGraphics.size() == toLoad.size()); Change-Id: I8fe7ee597de9f2385c029d38970bac030a91fc11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184810 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 6645e3d30011..3a8267b7fa29 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -522,9 +522,11 @@ void GraphicImportTask::doImport(GraphicImportContext& rContext) } else if(rContext.m_eLinkType == GfxLinkType::NativePng) { - if (!vcl::ImportPNG(*rContext.m_pStream, *rContext.m_pImportOutput, - rContext.m_nImportFlags | GraphicFilterImportFlags::UseExistingBitmap, - rContext.m_pAccess.get(), rContext.m_pAlphaAccess.get())) + vcl::ImportPNG(*rContext.m_pStream, *rContext.m_pImportOutput, + rContext.m_nImportFlags | GraphicFilterImportFlags::UseExistingBitmap, + rContext.m_pAccess.get(), rContext.m_pAlphaAccess.get()); + + if (!rContext.m_pImportOutput->moBitmap || rContext.m_pImportOutput->moBitmap->IsEmpty()) { rContext.m_nStatus = ERRCODE_GRFILTER_FILTERERROR; } @@ -631,9 +633,9 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra std::shared_ptr<Graphic> pGraphic; if (rContext.m_nStatus == ERRCODE_NONE && rContext.m_pImportOutput && rContext.m_pImportOutput->moBitmap) - { pGraphic = std::make_shared<Graphic>(*rContext.m_pImportOutput->moBitmap); - } + else + pGraphic = std::make_shared<Graphic>(); if (rContext.m_nStatus == ERRCODE_NONE && rContext.m_eLinkType != GfxLinkType::NONE) { @@ -659,8 +661,7 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra pGraphic->SetGfxLink(std::make_shared<GfxLink>(aGraphicContent, rContext.m_eLinkType)); } - if (rContext.m_nStatus == ERRCODE_NONE) - rGraphics.push_back(pGraphic); + rGraphics.push_back(pGraphic); } }