Skip to content

Commit

Permalink
When the control is not effectively visible the matrix could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
danipen committed Oct 25, 2022
1 parent a083fb5 commit d7bbd9d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AvaloniaEdit/Utils/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ public static Point SnapToDevicePixels(this Point p, IVisual targetVisual)
// Create a matrix to translate from control coordinates to device coordinates.
var m = targetVisual.TransformToVisual((Control)root) * Matrix.CreateScale(scaling);

if (m == null)
return p;

// Translate the point to device coordinates.
var devicePoint = p.Transform(m.Value);

Expand Down

0 comments on commit d7bbd9d

Please sign in to comment.