Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Johnson <bret.johnson@microsoft.com>2022-02-07 08:12:43 +0300
committerBret Johnson <bret.johnson@microsoft.com>2022-02-07 08:12:43 +0300
commit9bf088da711d4beb5a194cb636a3bdee7ba2676c (patch)
tree159253f60c2cc5c7ee08a24e91287e39a74803cf
parent78bc24fb825b0a6af277930105f8ef8b85163e78 (diff)
Protect against CurrentAppearance NRE
Fix AB#1468252 Apparently there are scenarios where CurrentAppearance is not set by the client on HostResourceProvider (UITools sets it but vsmac doesn't currently) nor is NSAppearance.CurrentAppearance set on the current thread (perhaps the thread is newly created and AppKit didn't get a chance to set it), causing bug 1468252. To protect against that, we check if both are null and in that case just assume it's light theme rather than generate an NRE.
-rw-r--r--Xamarin.PropertyEditing.Mac/HostResourceProvider.cs3
1 files changed, 2 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs
index 4d42f06..dd2b224 100644
--- a/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs
+++ b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs
@@ -39,7 +39,8 @@ namespace Xamarin.PropertyEditing.Mac
public virtual NSImage GetNamedImage (string name)
{
- if ((CurrentAppearance ?? NSAppearance.CurrentAppearance).Name.ToLower ().Contains ("dark")) {
+ NSAppearance currentAppearance = CurrentAppearance ?? NSAppearance.CurrentAppearance;
+ if (currentAppearance != null && currentAppearance.Name.ToLower ().Contains ("dark")) {
bool sel = name.EndsWith ("~sel");
if (sel)
name = name.Substring (0, name.Length - 4);