summaryrefslogtreecommitdiff
path: root/vcl/qa
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/qa
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/qa')
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx20
1 files changed, 4 insertions, 16 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 789b82ae42e6..45eb62921bcb 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -43,6 +43,8 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <unotools/streamwrap.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
+
using namespace ::com::sun::star;
static std::ostream& operator<<(std::ostream& rStrm, const Color& rColor)
@@ -87,6 +89,7 @@ class PdfExportTest : public test::BootstrapFixture, public unotest::MacrosTest
SvMemoryStream maMemory;
// Export the document as PDF, then parse it with PDFium.
DocumentHolder exportAndParse(const OUString& rURL, const utl::MediaDescriptor& rDescriptor);
+ std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
public:
PdfExportTest();
@@ -225,18 +228,11 @@ void PdfExportTest::setUp()
mxDesktop.set(frame::Desktop::create(mxComponentContext));
- FPDF_LIBRARY_CONFIG config;
- config.version = 2;
- config.m_pUserFontPaths = nullptr;
- config.m_pIsolate = nullptr;
- config.m_v8EmbedderSlot = 0;
- FPDF_InitLibraryWithConfig(&config);
+ mpPDFium = vcl::pdf::PDFiumLibrary::get();
}
void PdfExportTest::tearDown()
{
- FPDF_DestroyLibrary();
-
if (mxComponent.is())
mxComponent->dispose();
@@ -2061,14 +2057,6 @@ void PdfExportTest::testPdfImageResourceInlineXObjectRef()
aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
- // Init pdfium, vcl::ImportPDF() calls FPDF_DestroyLibrary after our setUp().
- FPDF_LIBRARY_CONFIG config;
- config.version = 2;
- config.m_pUserFontPaths = nullptr;
- config.m_pIsolate = nullptr;
- config.m_v8EmbedderSlot = 0;
- FPDF_InitLibraryWithConfig(&config);
-
// Parse the export result.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
maMemory.WriteStream(aFile);