From e6d82d159bacc7a98eda31d4cdc66ea3e791760b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 31 Mar 2023 23:04:51 +0100 Subject: [PATCH] browser/client: delete apps in OnBeforeClose --- src/browser/client.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/browser/client.cxx b/src/browser/client.cxx index 2e8e28a..24a1fff 100644 --- a/src/browser/client.cxx +++ b/src/browser/client.cxx @@ -1,5 +1,7 @@ #include "client.hxx" +#include + #include const char* app_overlay_html = "
"; @@ -85,6 +87,9 @@ Browser::Client::Client() { }; this->app_overlay_url = "http://bolt/app"; this->apps.push_back(Browser::Window(this, details)); + this->apps.push_back(Browser::Window(this, details)); + this->apps.push_back(Browser::Window(this, details)); + this->apps.push_back(Browser::Window(this, details)); } CefRefPtr Browser::Client::GetLifeSpanHandler() { @@ -106,8 +111,14 @@ bool Browser::Client::DoClose(CefRefPtr browser) { } void Browser::Client::OnBeforeClose(CefRefPtr browser) { - // note: last callback while the browser exists - it's too late to send process messages at this point fmt::print("[B] OnBeforeClose for browser {}\n", browser->GetIdentifier()); + this->apps.erase( + std::remove_if( + this->apps.begin(), + this->apps.end(), + [&browser](const Browser::Window& window){ return window.IsClosingWithHandle(browser->GetIdentifier()); } + ) + ); } bool Browser::Client::OnProcessMessageReceived(CefRefPtr browser, CefRefPtr frame, CefProcessId, CefRefPtr message) {