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

This commit is contained in:
Dustin L. Howett 2026-01-15 08:59:02 -06:00 committed by GitHub
parent e9a8301e73
commit a0c79b59e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -910,9 +910,18 @@ LRESULT WindowEmperor::_messageHandler(HWND window, UINT const message, WPARAM c
// which would change the _windows array, and invalidate our iterator and crash. // which would change the _windows array, and invalidate our iterator and crash.
// //
// We can prevent this by deferring Close() until after the erase() call. // 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; const auto strong = *it;
_windows.erase(it); _windows.erase(it);
strong->Close(); try
{
strong->Close();
}
CATCH_LOG();
break; break;
} }
} }