Fix a crash on pane close (#17886)

The underlying issue is that the "Pane" is used both as a model and as
a UI element and so a pane loses its content as soon as it is closed,
but the tree only gets reordered after the animation has finished.
This PR is truly just a hotfix, because it doesn't solve this issue,
it only adds checks to the function that crashes.

Closes #17869
Closes #17871

## Validation Steps Performed
* `Split pane` a few times
* Run the "Close all other panes" action
* Doesn't crash 

(cherry picked from commit bc6f3e22757415e42e658597c60b40c003941289)
Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgTEJYE
Service-Version: 1.21
This commit is contained in:
Leonard Hecker 2024-09-12 17:03:39 +02:00 committed by Dustin Howett
parent b6326cf23e
commit bdb67a382a

View File

@ -2955,13 +2955,13 @@ bool Pane::ContainsReadOnly() const
// - <none>
void Pane::CollectTaskbarStates(std::vector<winrt::TerminalApp::TaskbarState>& states)
{
if (_IsLeaf())
if (_content)
{
auto tbState{ winrt::make<winrt::TerminalApp::implementation::TaskbarState>(_content.TaskbarState(),
_content.TaskbarProgress()) };
states.push_back(tbState);
}
else
else if (_firstChild && _secondChild)
{
_firstChild->CollectTaskbarStates(states);
_secondChild->CollectTaskbarStates(states);