summaryrefslogtreecommitdiff
path: root/vcl/source/graphic/VectorGraphicSearch.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-31 11:50:20 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-03 13:32:01 +0200
commit067a8a954c8e1d8d6465a4ab5fb61e93f16c26c2 (patch)
tree26b9c6a16472a47b0aad4d156baaa73d9fe72ea5 /vcl/source/graphic/VectorGraphicSearch.cxx
parent40d682542f02d78b5ed6bd4fc0ba461a1a7fb5f1 (diff)
pdfium: only init pdfium library one 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. Change-Id: I5c7e5de7f8b97d10efb394c67c7a61b976c8d57c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95391 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/graphic/VectorGraphicSearch.cxx')
-rw-r--r--vcl/source/graphic/VectorGraphicSearch.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index fc7c9257e1f8..e8f7484320e3 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -10,6 +10,8 @@
#include <vcl/VectorGraphicSearch.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
+
#include <sal/config.h>
#include <fpdf_doc.h>
@@ -18,10 +20,12 @@
class VectorGraphicSearch::Implementation
{
public:
+ std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
FPDF_DOCUMENT mpPdfDocument;
Implementation()
- : mpPdfDocument(nullptr)
+ : mpPDFium(vcl::pdf::PDFiumLibrary::get())
+ , mpPdfDocument(nullptr)
{
}
@@ -180,19 +184,12 @@ VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
: mpImplementation(std::make_unique<VectorGraphicSearch::Implementation>())
, maGraphic(rGraphic)
{
- FPDF_LIBRARY_CONFIG aConfig;
- aConfig.version = 2;
- aConfig.m_pUserFontPaths = nullptr;
- aConfig.m_pIsolate = nullptr;
- aConfig.m_v8EmbedderSlot = 0;
- FPDF_InitLibraryWithConfig(&aConfig);
}
VectorGraphicSearch::~VectorGraphicSearch()
{
mpSearchContext.reset();
mpImplementation.reset();
- FPDF_DestroyLibrary();
}
bool VectorGraphicSearch::search(OUString const& rSearchString, SearchStartPosition eStartPosition)