diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-31 11:50:20 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-09 15:40:37 +0200 |
commit | b7de766b4dc5b4810277069bcf53a9f3737e87da (patch) | |
tree | 6372a6d6b42bccd47bd5ad09c353b44ccf317483 /svx/source | |
parent | 047351c2f9997dcd345c00c1bc1f0d72c8d62ed9 (diff) |
pdfium: only init pdfium library once and destroy on LO exit
With more and more usage of PDFium, it is hard to keep track of
the life-time of the PDFium library, so it can happen that a
FPDF_DestroyLibrary happens when we still have another instance
where PDFium is still use. The result of this is a crash. To
prevent this, just initialize the library once and delete, when
on LO exit.
This can be improved in the future to only keep the library
active when in actual use.
[ Leaving out the vector graphic search bits, the motivation is to just
have this in libreoffice-7-0, so that recent pdf sig verify improvements
can be backported. ]
(cherry picked from commit 067a8a954c8e1d8d6465a4ab5fb61e93f16c26c2)
Conflicts:
vcl/source/graphic/VectorGraphicSearch.cxx
Change-Id: I5c7e5de7f8b97d10efb394c67c7a61b976c8d57c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102317
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/svdraw/svdpdf.cxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdpdf.hxx | 4 |
2 files changed, 6 insertions, 12 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index b392e9523f79..66b37df2aee4 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -145,6 +145,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools: , mnPageCount(0) , mdPageWidthPts(0) , mdPageHeightPts(0) + , mpPDFium(vcl::pdf::PDFiumLibrary::get()) { mpVD->EnableOutput(false); mpVD->SetLineColor(); @@ -158,13 +159,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools: svl::Items<EE_ITEMS_START, EE_ITEMS_END>{}); checkClip(); - FPDF_LIBRARY_CONFIG aConfig; - aConfig.version = 2; - aConfig.m_pUserFontPaths = nullptr; - aConfig.m_pIsolate = nullptr; - aConfig.m_v8EmbedderSlot = 0; - FPDF_InitLibraryWithConfig(&aConfig); - // Load the buffer using pdfium. mpPdfDocument = FPDF_LoadMemDocument(mpPdfData->data(), mpPdfData->size(), /*password=*/nullptr); @@ -197,11 +191,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools: mnPageCount = FPDF_GetPageCount(mpPdfDocument); } -ImpSdrPdfImport::~ImpSdrPdfImport() -{ - FPDF_CloseDocument(mpPdfDocument); - FPDF_DestroyLibrary(); -} +ImpSdrPdfImport::~ImpSdrPdfImport() { FPDF_CloseDocument(mpPdfDocument); } void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex) diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx index 70b5a44e4ddf..3624b50ba28d 100644 --- a/svx/source/svdraw/svdpdf.hxx +++ b/svx/source/svdraw/svdpdf.hxx @@ -42,6 +42,8 @@ #include <postwin.h> #include <fpdfview.h> +#include <vcl/filter/PDFiumLibrary.hxx> + // Forward Declarations class SfxItemSet; @@ -205,6 +207,8 @@ class ImpSdrPdfImport final tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const; Point PointsToLogic(double x, double y) const; + std::shared_ptr<vcl::pdf::PDFium> mpPDFium; + // check for clip and evtl. fill maClip void checkClip(); bool isClip() const; |