Skip to content

Commit 8feed98

Browse files
carlos-zamoraDHowett
authored andcommitted
Fix crash when closing multiple panes simultaneously (#19023)
Fixes a crash when multiple panes were closed simultaneously (i.e. using broadcast input). The root cause of this crash was that we would get a null pointer exception when trying to access a member/function off of a null `_content`. This is because `Pane::_CloseChild()` would always pass over the content from the non-closed pane and attempt to hook everything up to it. The fix was to operate similarly to `Pane::Close()` and raise a `Closed` event and return early. Since there's no alternative content to attach to, might as well just close the entire pane. This propagates up the stack of listeners to update the UI appropriately and close the parent pane and eventually the entire tab, if necessary.   Closes #18071 Closes #17432 ## Validation Steps Performed 1. Open 2 panes 2. Use broadcast input to send "exit" to both panes 3. ✅ Terminal doesn't crash and the tab closes gracefully (cherry picked from commit 6bf315a) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgb3LNo Service-Version: 1.22
1 parent 7394807 commit 8feed98

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/cascadia/TerminalApp/Pane.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,13 @@ void Pane::_CloseChild(const bool closeFirst)
14141414

14151415
// take the control, profile, id and isDefTermSession of the pane that _wasn't_ closed.
14161416
_setPaneContent(remainingChild->_takePaneContent());
1417+
if (!_content)
1418+
{
1419+
// GH#18071: our content is still null after taking the other pane's content,
1420+
// so just notify our parent that we're closed.
1421+
Closed.raise(nullptr, nullptr);
1422+
return;
1423+
}
14171424
_id = remainingChild->Id();
14181425

14191426
// Revoke the old event handlers. Remove both the handlers for the panes

0 commit comments

Comments
 (0)