From 57b02e153de798edb2fc415e19792e64f191a349 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 19 Jul 2022 11:45:10 +0200 Subject: [PATCH] fix: potential hang on print settings failure (#34892) --- patches/chromium/printing.patch | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index 460fb3b6d5bc..a602cca1f008 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -78,7 +78,7 @@ index 331a084371402b5a2440b5d60feac8f0189e84b9..6755d1f497cef4deea6b83df1d8720dc : PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3; } diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc -index d9ae000f1348529ab849349d7562dbb04fe9fd16..cf66978761f5dda2f8958234d62c3cf11ae4cf9c 100644 +index d9ae000f1348529ab849349d7562dbb04fe9fd16..fcfeffd86bd897467b12bf1aba4aaac09986cfd9 100644 --- a/chrome/browser/printing/print_job_worker.cc +++ b/chrome/browser/printing/print_job_worker.cc @@ -20,7 +20,6 @@ @@ -97,7 +97,7 @@ index d9ae000f1348529ab849349d7562dbb04fe9fd16..cf66978761f5dda2f8958234d62c3cf1 #include "printing/backend/print_backend.h" #include "printing/buildflags/buildflags.h" #include "printing/mojom/print.mojom.h" -@@ -222,16 +222,21 @@ void PrintJobWorker::UpdatePrintSettings(base::Value::Dict new_settings, +@@ -222,16 +222,19 @@ void PrintJobWorker::UpdatePrintSettings(base::Value::Dict new_settings, #endif // BUILDFLAG(IS_LINUX) && defined(USE_CUPS) } @@ -111,12 +111,10 @@ index d9ae000f1348529ab849349d7562dbb04fe9fd16..cf66978761f5dda2f8958234d62c3cf1 - result = printing_context_->UpdatePrintSettings(std::move(new_settings)); + // Reset settings from previous print job + printing_context_->ResetSettings(); -+ mojom::ResultCode get_default_result = printing_context_->UseDefaultSettings(); -+ if (get_default_result == mojom::ResultCode::kSuccess) { -+ mojom::ResultCode update_result = -+ printing_context_->UpdatePrintSettings(std::move(new_settings)); -+ GetSettingsDone(std::move(callback), update_result); -+ } ++ mojom::ResultCode result_code = printing_context_->UseDefaultSettings(); ++ if (result_code == mojom::ResultCode::kSuccess) ++ result_code = printing_context_->UpdatePrintSettings(std::move(new_settings)); ++ GetSettingsDone(std::move(callback), result_code); } - GetSettingsDone(std::move(callback), result); }