Skip to content

Commit 5a942bc

Browse files
authored
Avoid an access violation in pane animation if the child is closed (#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!
1 parent 64aa911 commit 5a942bc

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/cascadia/TerminalApp/Pane.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,22 +1189,27 @@ void Pane::_SetupEntranceAnimation()
11891189
if (auto pane{ weakThis.lock() })
11901190
{
11911191
auto child = isFirstChild ? pane->_firstChild : pane->_secondChild;
1192-
auto childGrid = child->_root;
1193-
if (auto control = child->_control)
1192+
1193+
// ensure the child was not release in meanwhile
1194+
if (child)
11941195
{
1195-
if (splitWidth)
1196-
{
1197-
control.Width(NAN);
1198-
childGrid.Width(NAN);
1199-
childGrid.HorizontalAlignment(HorizontalAlignment::Stretch);
1200-
control.HorizontalAlignment(HorizontalAlignment::Stretch);
1201-
}
1202-
else
1196+
auto childGrid = child->_root;
1197+
if (auto control = child->_control)
12031198
{
1204-
control.Height(NAN);
1205-
childGrid.Height(NAN);
1206-
childGrid.VerticalAlignment(VerticalAlignment::Stretch);
1207-
control.VerticalAlignment(VerticalAlignment::Stretch);
1199+
if (splitWidth)
1200+
{
1201+
control.Width(NAN);
1202+
childGrid.Width(NAN);
1203+
childGrid.HorizontalAlignment(HorizontalAlignment::Stretch);
1204+
control.HorizontalAlignment(HorizontalAlignment::Stretch);
1205+
}
1206+
else
1207+
{
1208+
control.Height(NAN);
1209+
childGrid.Height(NAN);
1210+
childGrid.VerticalAlignment(VerticalAlignment::Stretch);
1211+
control.VerticalAlignment(VerticalAlignment::Stretch);
1212+
}
12081213
}
12091214
}
12101215
}

0 commit comments

Comments
 (0)