From 431559fd83d27333169e0c6f37786388d4e4e1ef Mon Sep 17 00:00:00 2001 From: Don-Vito Date: Wed, 11 Nov 2020 01:25:57 +0200 Subject: [PATCH] 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! (cherry picked from commit 5a942bcb6fe935f997dadf0a80109d56d8fd610f) --- src/cascadia/TerminalApp/Pane.cpp | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 749a02bd9c5..b7d94d87e06 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -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); + } } } }