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

Commit dca85f8

Browse files
committed
[Debugger] Make sure tooltip request wasn't cancelled before showing
After the context switch to the main thread in order to show the tooltip, check that the request hasn't been cancelled due to the editor window being closed in the meantime (for example). Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1002160/
1 parent e319e57 commit dca85f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/DebuggerQuickInfoSource.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ private async Task EvaluateAndShowTooltipAsync (IAsyncQuickInfoSession session,
146146
// and do our own thing, notice VS does same thing
147147
await session.DismissAsync ();
148148
await provider.joinableTaskContext.Factory.SwitchToMainThreadAsync ();
149+
150+
if (cancellationToken.IsCancellationRequested)
151+
return;
152+
149153
lastView = view;
150154

151155
val.Name = debugInfo.Text;
@@ -177,6 +181,11 @@ private async Task EvaluateAndShowTooltipAsync (IAsyncQuickInfoSession session,
177181
var bounds = view.TextViewLines.GetCharacterBounds (point);
178182
var rect = new CoreGraphics.CGRect (bounds.Left - view.ViewportLeft, bounds.Top - view.ViewportTop, bounds.Width, bounds.Height);
179183

184+
if (cocoaView.IsClosed) {
185+
LoggingService.LogWarning ("Editor window has been closed before debugger tooltip was shown. How did this happen?");
186+
return;
187+
}
188+
180189
window.Show (rect, cocoaView.VisualElement, AppKit.NSRectEdge.MaxXEdge);
181190
#else
182191
throw new NotImplementedException ();

0 commit comments

Comments
 (0)