Skip to content

Commit 488efbe

Browse files
mandel-macaqueGitHub Actions Autoformatterharitha-mohan
authored
[AppKit] Remove nullability warning. (#17411)
Maybe a bad merge or we missed it. --------- Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com> Co-authored-by: Haritha Mohan <110641567+haritha-mohan@users.noreply.github.com>
1 parent f021358 commit 488efbe

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/AppKit/NSView.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public SortData (Func<NSView?, NSView?, NSComparisonResult> comparer)
3838
#endif
3939
static nint view_compare (IntPtr view1, IntPtr view2, IntPtr context)
4040
{
41-
var data = (SortData) GCHandle.FromIntPtr (context).Target;
41+
var data = GCHandle.FromIntPtr (context).Target as SortData;
42+
// should never happen, but we must be ready and not crash
43+
if (data is null)
44+
return (nint) (long) NSComparisonResult.Same;
45+
4246
try {
4347
var a = Runtime.GetNSObject (view1) as NSView;
4448
var b = Runtime.GetNSObject (view2) as NSView;

0 commit comments

Comments
 (0)