From c7f0d0addb38f04b846f15fd27131155692082e6 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 24 Feb 2025 10:27:36 -0800 Subject: [PATCH] Fix leaking the contents of the first tab in the first window (#18621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found this one completely randomly. ## Validation Steps Performed * Open 2 windows with 1 tab each * Click the X button on the tab in the 1st window * OpenConsole/etc. is cleaned up ✅ --------- Co-authored-by: Dustin L. Howett --- src/cascadia/WindowsTerminal/IslandWindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cascadia/WindowsTerminal/IslandWindow.cpp b/src/cascadia/WindowsTerminal/IslandWindow.cpp index 1e2ced901e..80932f3322 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/IslandWindow.cpp @@ -95,6 +95,12 @@ void IslandWindow::Close() if (_source) { + // BODGY + // 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); + _source.Close(); _source = nullptr; }