Skip to content

Commit

Permalink
Fix a crash on exit with the command palette open (#13778)
Browse files Browse the repository at this point in the history
Fixes MSFT:38775539
Might also fix MSFT:38614563

Looking at this code should be pretty clear what's going on. On exit, the XAML root is already nulled out. But here, we're just yolo'ing and assuming it exists (why wouldn't it). So yea. This is like weirdly high percent of crashes internally, but that's not from real users. Real users, I suspect hit this as like .3% of our crashes. Not zero, but _low_.

* [x] tested manually

<hr>

May also be related to...
* MSFT:40602905
* MSFT:40602904
* MSFT:40412800
* MSFT:35213459 <---has links

(cherry picked from commit 64bcc0b)
Service-Card-Id: 85486788
Service-Version: 1.15
  • Loading branch information
zadjii-msft authored and DHowett committed Sep 6, 2022
1 parent 038ad3b commit a0eaea8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cascadia/TerminalApp/CommandPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,13 @@ namespace winrt::TerminalApp::implementation
return;
}

auto focusedElementOrAncestor = Input::FocusManager::GetFocusedElement(this->XamlRoot()).try_as<DependencyObject>();
auto root = this->XamlRoot();
if (!root)
{
return;
}

auto focusedElementOrAncestor = Input::FocusManager::GetFocusedElement(root).try_as<DependencyObject>();
while (focusedElementOrAncestor)
{
if (focusedElementOrAncestor == *this)
Expand Down

0 comments on commit a0eaea8

Please sign in to comment.