Skip to content

Commit

Permalink
WPF - CompositionTargetRenderHandler add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Feb 15, 2022
1 parent 28b7406 commit 3f759a7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using Rect = CefSharp.Structs.Rect;

namespace CefSharp.Wpf.Rendering.Experimental
Expand All @@ -25,6 +24,12 @@ public class CompositionTargetRenderHandler : IRenderHandler
private readonly object lockObj = new object();
private ChromiumWebBrowser browser;

/// <summary>
/// Default constructor
/// </summary>
/// <param name="browser">ChromiumWebBrowser instance</param>
/// <param name="dpiX">DPI X</param>
/// <param name="dpiY">DPI Y</param>
public CompositionTargetRenderHandler(ChromiumWebBrowser browser, double dpiX, double dpiY)
{
this.browser = browser;
Expand Down Expand Up @@ -103,7 +108,7 @@ private void OnRendering(object sender, EventArgs args)

private void UpdateImage(PaintElement element)
{
if (element.IsDirty && element.Image != null)
if (element != null && element.IsDirty && element.Image != null)
{
var bitmap = element.Image.Source as WriteableBitmap;
if (bitmap == null || bitmap.PixelWidth != element.Width || bitmap.PixelHeight != element.Height)
Expand Down

0 comments on commit 3f759a7

Please sign in to comment.