Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 94332cf

Browse files
authored
Merge pull request #9405 from mono/dev/anvod/1026106
Fixes 1026106 - in some cases, NSEvent seems to have been null
2 parents 95c46e0 + cfe2c4b commit 94332cf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using AppKit;
3030
using CoreGraphics;
3131
using Foundation;
32+
using MonoDevelop.Core;
3233
using MonoDevelop.Ide;
3334
#endif
3435

@@ -136,6 +137,20 @@ public static void ShowContextMenu (NSView parent, int x, int y, NSMenu menu, bo
136137
0, 0,
137138
parent.Window.WindowNumber,
138139
null, 0, 0, 0);
140+
141+
// the following lines are here to dianose & fix VSTS 1026106 - we were getting
142+
// a SigSegv from here and it is likely caused by NSEvent being null, however
143+
// it's worth leaving Debug checks in just to be on the safe side
144+
if (tmp_event == null) {
145+
// since this is often called outside of a try/catch loop, we'll just
146+
// log an error and not throw the exception
147+
LoggingService.LogInternalError (new ArgumentNullException (nameof(tmp_event)));
148+
return;
149+
}
150+
151+
System.Diagnostics.Debug.Assert (parent != null, "Parent was modified (set to null) during execution.");
152+
System.Diagnostics.Debug.Assert (menu != null, "Menu was modified (set to null) during execution.");
153+
139154
NSMenu.PopUpContextMenu (menu, tmp_event, parent);
140155
}
141156
}
@@ -305,4 +320,4 @@ void MenuWillHighlightItem (NSMenu menu, NSMenuItem willHighlightItem)
305320
}
306321
}
307322
#endif
308-
}
323+
}

0 commit comments

Comments
 (0)