Wrap window shutdown in a top-level exception handler (#19743)

(cherry picked from commit a0c79b59e6b6d89e4f013a784d3c890076d549a5)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgjsATs
Service-Version: 1.24
This commit is contained in:
Dustin L. Howett 2026-01-15 08:59:02 -06:00 committed by Dustin L. Howett
parent a3d508a487
commit 633cd6e9dc

View File

@ -909,9 +909,18 @@ LRESULT WindowEmperor::_messageHandler(HWND window, UINT const message, WPARAM c
// which would change the _windows array, and invalidate our iterator and crash.
//
// We can prevent this by deferring Close() until after the erase() call.
//
// Wrapping it in an exception handler will prevent us from losing track of the window count, at
// the perceived cost of leaking all the resources. However, the resources were being leaked
// anyway (since we threw and exited this message handler) so this at least gives back our
// deterministic window count management.
const auto strong = *it;
_windows.erase(it);
strong->Close();
try
{
strong->Close();
}
CATCH_LOG();
break;
}
}