Skip to content

Commit 56f862e

Browse files
reseulrozele
authored andcommitted
Merged PR 166415: Fix a crash on start (microsoft#1829)
A ResourceContext.GetForCurrentView used in i18NUtil fails miserably when the view has no CoreWindow. We use now a GetForViewIndependentUse that seems to fare better.
1 parent 90f1d6d commit 56f862e

File tree

1 file changed

+5
-2
lines changed
  • ReactWindows/ReactNative.Shared/Modules/I18N

1 file changed

+5
-2
lines changed

ReactWindows/ReactNative.Shared/Modules/I18N/I18NUtil.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Portions derived from React Native:
33
// Copyright (c) 2015-present, Facebook, Inc.
44
// Licensed under the MIT License.
@@ -88,7 +88,10 @@ private static bool IsDeviceRightToLeft
8888
get
8989
{
9090
#if WINDOWS_UWP
91-
return ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"] == "RTL";
91+
// We use GetForViewIndependentUse because the customary GetForCurrentView throws exception when
92+
// an associated CoreWindow is not present, condition that happens during background activation scenarios.
93+
// GetForViewIndependentUse is good enough for the LayoutDirection resource (it's not view or display dependent)
94+
return ResourceContext.GetForViewIndependentUse().QualifierValues["LayoutDirection"] == "RTL";
9295
#else
9396
return CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
9497
#endif

0 commit comments

Comments
 (0)