Skip to content

Commit eafe9c8

Browse files
committed
Wrap Application::Current in try/catch since that breaks tests
1 parent 82ad8bb commit eafe9c8

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,20 @@ namespace winrt::TerminalApp::implementation
6363
_tabView = _tabRow.TabView();
6464
_rearranging = false;
6565

66-
// GH#3581 - There's a platform limitation that causes us to crash when we rearrange tabs.
67-
// Xaml tries to send a drag visual (to wit: a screenshot) to the drag hosting process,
68-
// but that process is running at a different IL than us.
69-
// For now, we're disabling elevated drag.
70-
const auto isElevated = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsElevated();
66+
// GH#2455 - Make sure to try/catch calls to Application::Current,
67+
// because that _won't_ be an instance of TerminalApp::App in the
68+
// LocalTests
69+
auto isElevated = false;
70+
try
71+
{
72+
// GH#3581 - There's a platform limitation that causes us to crash when we rearrange tabs.
73+
// Xaml tries to send a drag visual (to wit: a screenshot) to the drag hosting process,
74+
// but that process is running at a different IL than us.
75+
// For now, we're disabling elevated drag.
76+
isElevated = ::winrt::Windows::UI::Xaml::Application::Current().as<::winrt::TerminalApp::App>().Logic().IsUwp();
77+
}
78+
CATCH_LOG();
79+
7180
_tabView.CanReorderTabs(!isElevated);
7281
_tabView.CanDragTabs(!isElevated);
7382

@@ -406,6 +415,9 @@ namespace winrt::TerminalApp::implementation
406415

407416
// add static items
408417
{
418+
// GH#2455 - Make sure to try/catch calls to Application::Current,
419+
// because that _won't_ be an instance of TerminalApp::App in the
420+
// LocalTests
409421
auto isUwp = false;
410422
try
411423
{

0 commit comments

Comments
 (0)