From df482f6b12ff664698408d5ba270757c5d6aa6d2 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 18 Aug 2022 12:26:30 -0400 Subject: [PATCH] Fix crashes with PrintToPDF (fixes issue #3373) - Configure the DPI setting (see https://crrev.com/40e28bcba3) - Call StopWorker on the UI thread (see https://crrev.com/564fa1d8a4) --- libcef/browser/printing/print_view_manager.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libcef/browser/printing/print_view_manager.cc b/libcef/browser/printing/print_view_manager.cc index 889143a54..487d0a100 100644 --- a/libcef/browser/printing/print_view_manager.cc +++ b/libcef/browser/printing/print_view_manager.cc @@ -37,6 +37,7 @@ #include "content/public/browser/web_contents_observer.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "printing/metafile_skia.h" +#include "printing/units.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #if BUILDFLAG(IS_LINUX) @@ -67,8 +68,8 @@ void FillInDictionaryFromPdfPrintSettings( print_settings.Set(kSettingDeviceName, ""); print_settings.Set(kSettingRasterizePdf, false); print_settings.Set(kSettingPreviewModifiable, false); - print_settings.Set(kSettingDpiHorizontal, 0); - print_settings.Set(kSettingDpiVertical, 0); + print_settings.Set(kSettingDpiHorizontal, printing::kDefaultPdfDpi); + print_settings.Set(kSettingDpiVertical, printing::kDefaultPdfDpi); print_settings.Set(kSettingPagesPerSheet, 1); // User defined settings. @@ -137,9 +138,7 @@ void StopWorker(int document_cookie) { std::unique_ptr printer_query = queue->PopPrinterQuery(document_cookie); if (printer_query.get()) { - content::GetIOThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce(&PrinterQuery::StopWorker, std::move(printer_query))); + printer_query->StopWorker(); } }