From 30ef1f461d778429898542a1da5b799361b169bb Mon Sep 17 00:00:00 2001 From: Tushar Singh Date: Mon, 13 May 2024 22:11:08 +0530 Subject: [PATCH] Fix single-tab window tear-off crash (#17251) ## Validation Steps Performed - Opened multi-tab terminal window with Narrator. Narrator can read characters from the tabs. - Started a drag and drop (tear-off) of a tab, and it didn't crash. This was repeated multiple times. --- src/cascadia/TerminalControl/TermControl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index c1c7cc73e5..97fbdd46dc 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1055,8 +1055,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // MSFT 33353327: We're purposefully not using _initializedTerminal to ensure we're fully initialized. // Doing so makes us return nullptr when XAML requests an automation peer. // Instead, we need to give XAML an automation peer, then fix it later. - if (!_IsClosing()) + if (!_IsClosing() && !_detached) { + // It's unexpected that interactivity is null even when we're not closing or in detached state. + THROW_HR_IF_NULL(E_UNEXPECTED, _interactivity); + // create a custom automation peer with this code pattern: // (https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers) if (const auto& interactivityAutoPeer{ _interactivity.OnCreateAutomationPeer() })