Skip to content

Commit

Permalink
Fix stack overflow in offset_bezierpath
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Jun 17, 2024
1 parent cae34cc commit 7bee9bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utilities/texture_atlas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function primitive_uv_offset_width(atlas::TextureAtlas, marker::Observable, font
return lift((m, f)-> primitive_uv_offset_width(atlas, m, f), marker, font; ignore_equal_values=true)
end

_bcast(x::Vec) = (x,)
_bcast(x::Vec) = Ref(x)
_bcast(x) = x

# Calculates the scaling factor from unpadded size -> padded size
Expand Down Expand Up @@ -534,7 +534,7 @@ function offset_bezierpath(atlas::TextureAtlas, bp::BezierPath, markersize::Vec2
end

function offset_bezierpath(atlas::TextureAtlas, bp, scale, offset)
return offset_bezierpath.(Ref(atlas), bp, _bcast(scale), _bcast(offset))
return offset_bezierpath.(Ref(atlas), bp, Vec2d.(_bcast(scale)), Vec2d.(_bcast(offset)))
end

function offset_marker(atlas::TextureAtlas, marker::Union{T, AbstractVector{T}}, font, markersize, markeroffset) where T <: BezierPath
Expand Down
13 changes: 13 additions & 0 deletions test/boundingboxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,16 @@ end
@test data_limits(p) bb1
@test boundingbox(p) bb3
end

@testset "issue 3960" begin
fig = Figure()
ax = Axis(fig[1, 1])
triangle = BezierPath([
MoveTo(Point(0, 0)),
LineTo(Point(1, 0)),
LineTo(Point(0, 1)),
ClosePath()
])
sc = scatter!(ax, Point(0, 0), marker=triangle, markerspace=:data)
data_limits(sc) # doesn't stackoverflow
end

0 comments on commit 7bee9bf

Please sign in to comment.