From 59f3b143ef94b4d5630ad8d3b290760f1b9200d6 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 22 Oct 2024 16:17:54 -0400 Subject: [PATCH] mac: cefclient: Fix window.close() with --hide-window-on-close (fixes #3660) --- tests/cefclient/browser/views_window.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cefclient/browser/views_window.cc b/tests/cefclient/browser/views_window.cc index fe6aa765a..497e189f5 100644 --- a/tests/cefclient/browser/views_window.cc +++ b/tests/cefclient/browser/views_window.cc @@ -817,9 +817,11 @@ void ViewsWindow::OnWindowBoundsChanged(CefRefPtr window, bool ViewsWindow::CanClose(CefRefPtr window) { CEF_REQUIRE_UI_THREAD(); + CefRefPtr browser = browser_view_->GetBrowser(); + #if defined(OS_MAC) // On MacOS we might hide the window instead of closing it. - if (hide_on_close_) { + if (hide_on_close_ && browser && !browser->GetHost()->IsReadyToBeClosed()) { if (window->IsFullscreen()) { // Need to exit fullscreen mode before hiding the window. // Execution continues in OnWindowFullscreenTransition. @@ -833,7 +835,6 @@ bool ViewsWindow::CanClose(CefRefPtr window) { #endif // Allow the window to close if the browser says it's OK. - CefRefPtr browser = browser_view_->GetBrowser(); if (browser) { return browser->GetHost()->TryCloseBrowser(); }