From 5d70f2e44883c0f952bcd328bd3f1ab37e21812c Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 10:19:51 +0100 Subject: [PATCH] WebView2: a closing secondary window keeps its unload delay until its close is posted (#708) Answers CodeRabbit's review of #712: a full message queue refuses PostMessageW, and finishUnload() had already stopped the delay, so nothing tried again and the hidden window kept its controller until the first window ended. --- include/webfront/frontend/WebView2.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/webfront/frontend/WebView2.hpp b/include/webfront/frontend/WebView2.hpp index dba3ea3d..fdc34daf 100644 --- a/include/webfront/frontend/WebView2.hpp +++ b/include/webfront/frontend/WebView2.hpp @@ -563,9 +563,10 @@ class Session : public std::enable_shared_from_this { } } void finishUnload() noexcept { - stopUnloadTimer(); - if (window) - PostMessageW(window, WM_CLOSE, unloadedClose, 0); + // The delay repeats until the close is posted: a full message queue refuses the post, and the next expiry tries + // again instead of leaving the hidden window and its controller until the first window ends. + if (window && PostMessageW(window, WM_CLOSE, unloadedClose, 0)) + stopUnloadTimer(); } void stopUnloadTimer() noexcept { if (unloadTimer && window)