From ad9bf6b04193d4d4a4194f89108dcea2ca06a48d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:21:57 -0400 Subject: [PATCH] fix: Linux crash after `webContents.print()` with no parent window (#44285) fix: Linux crash after print with no parent window Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- patches/chromium/printing.patch | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index 708a36094854..412aa758564b 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -926,3 +926,23 @@ index 7a65f7f2d68edb74fbaf74fe41949ed9cc198b25..4d7c59e93d71b624d4e93e643932c816 namespace sandbox::policy { base::FilePath GetCanonicalPath(const base::FilePath& path) { +diff --git a/ui/gtk/gtk_util.cc b/ui/gtk/gtk_util.cc +index d86fbcf969f2fa0d176ead903703ab612e5464c2..6b963ea8401d20e655d068a69105586814bab320 100644 +--- a/ui/gtk/gtk_util.cc ++++ b/ui/gtk/gtk_util.cc +@@ -227,9 +227,13 @@ aura::Window* GetAuraTransientParent(GtkWidget* dialog) { + } + + void ClearAuraTransientParent(GtkWidget* dialog, aura::Window* parent) { ++ if (!parent || !parent->GetHost()) { ++ return; ++ } ++ + g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, nullptr); +- GtkUi::GetPlatform()->ClearTransientFor( +- parent->GetHost()->GetAcceleratedWidget()); ++ gfx::AcceleratedWidget parent_id = parent->GetHost()->GetAcceleratedWidget(); ++ GtkUi::GetPlatform()->ClearTransientFor(parent_id); + } + + base::OnceClosure DisableHostInputHandling(GtkWidget* dialog,