Skip to content

Commit e5749ad

Browse files
committed
WPF - Handle InvalidOperationException for Resize Hack
Assignment and check are on different threads, take local copy of struct to avoid threading null pointer. Feedback in 0d67b05#commitcomment-34649134 Issue #2779
1 parent 9766360 commit e5749ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,16 @@ Rect IRenderWebBrowser.GetViewRect()
784784
/// <returns>View Rectangle</returns>
785785
protected virtual Rect GetViewRect()
786786
{
787-
if (resizeHackForIssue2779Size == null)
787+
//Take a local copy as the value is set on a different thread,
788+
//Its possible the struct is set to null after our initial check.
789+
var resizeRect = resizeHackForIssue2779Size;
790+
791+
if (resizeRect == null)
788792
{
789793
return viewRect;
790794
}
791795

792-
var size = resizeHackForIssue2779Size.Value;
796+
var size = resizeRect.Value;
793797

794798
return new Rect(0, 0, size.Width, size.Height);
795799
}

0 commit comments

Comments
 (0)