Skip to content

Commit

Permalink
Avoid an access violation in pane animation if the child is closed (#…
Browse files Browse the repository at this point in the history
…8218)

Some UTs crash with access violation, that occurs during pane animation.
The reason for this is a race, upon which the pane is closed (set to
nullptr) before the parent is animated.  Added a simple check against
null.  Doubt it can happen in production, yet worth taking care!

(cherry picked from commit 5a942bc)
  • Loading branch information
Don-Vito authored and DHowett committed Jan 25, 2021
1 parent 109f9c4 commit 431559f
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,22 +1190,27 @@ void Pane::_SetupEntranceAnimation()
if (auto pane{ weakThis.lock() })
{
auto child = isFirstChild ? pane->_firstChild : pane->_secondChild;
auto childGrid = child->_root;
if (auto control = child->_control)

// ensure the child was not release in meanwhile
if (child)
{
if (splitWidth)
{
control.Width(NAN);
childGrid.Width(NAN);
childGrid.HorizontalAlignment(HorizontalAlignment::Stretch);
control.HorizontalAlignment(HorizontalAlignment::Stretch);
}
else
auto childGrid = child->_root;
if (auto control = child->_control)
{
control.Height(NAN);
childGrid.Height(NAN);
childGrid.VerticalAlignment(VerticalAlignment::Stretch);
control.VerticalAlignment(VerticalAlignment::Stretch);
if (splitWidth)
{
control.Width(NAN);
childGrid.Width(NAN);
childGrid.HorizontalAlignment(HorizontalAlignment::Stretch);
control.HorizontalAlignment(HorizontalAlignment::Stretch);
}
else
{
control.Height(NAN);
childGrid.Height(NAN);
childGrid.VerticalAlignment(VerticalAlignment::Stretch);
control.VerticalAlignment(VerticalAlignment::Stretch);
}
}
}
}
Expand Down

0 comments on commit 431559f

Please sign in to comment.