Compare commits

...

1 Commits

Author SHA1 Message Date
Dustin L. Howett
2d746ebae0 Guard IslandWindow shutdown against exploding?
During shutdown (specifically from the right-click menu in the terminal)
XAML would throw an exception that we traced back to resetting the
content of the Island.

```
Exception thrown at 0x00007FF95E72B5EC (KernelBase.dll) in
WindowsTerminal.exe: WinRT originate error - 0x800F1000 : 'Child
collection must not be modified during measure or arrange.'.
```

This made it out into the catch around the window message handler and
resulted in the window not being closed after being emptied out.

Closes #19312
2025-09-05 14:06:41 -05:00

View File

@@ -102,7 +102,15 @@ void IslandWindow::Close()
// WinUI will strongly hold onto the first DesktopWindowXamlSource that is created.
// If we don't manually set the Content() to null first, closing that first window
// will leak all of its contents permanently.
_source.Content(nullptr);
//
// However, sometimes resetting the content during showdown throws an exception.
// We want to continue shutting down, even if this failed (and just leak the
// content if that's what it is going to do.)
try
{
_source.Content(nullptr);
}
CATCH_LOG();
_source.Close();
_source = nullptr;