Browse Source

fix: Linux crash after `webContents.print()` with no parent window (#44283)

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 <[email protected]>
trop[bot] 6 months ago
parent
commit
2f247ad050
1 changed files with 20 additions and 0 deletions
  1. 20 0
      patches/chromium/printing.patch

+ 20 - 0
patches/chromium/printing.patch

@@ -894,3 +894,23 @@ index e89fd87753bad3c5663fa53f8dcc4542e7e307e5..2b433a0705234af6f9808ee741a9795d
  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,