Skip to content

Commit

Permalink
Fix a hang due to limits! being called recursively
Browse files Browse the repository at this point in the history
Fixes #3564

Restricting the sans axis arguments to the expected types prevents the
method from being called in a non-terminating loop which was the case
if, for example, the function was called with an indexed Figure instead
of an Axis; calling limits! without a current axis also resulted in a
stack overflow.
  • Loading branch information
Sagnac committed Jan 27, 2024
1 parent 5c8d07c commit 34e84ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,10 @@ function limits!(ax::Axis, rect::Rect2)
Makie.ylims!(ax, ymin, ymax)
end

function limits!(args...)
limits!(current_axis(), args...)
function limits!(args::Union{Nothing, Real, HyperRectangle}...)
axis = current_axis()
axis isa Nothing && error("There is no currently active axis!")
limits!(axis, args...)
end

Makie.transform_func(ax::Axis) = Makie.transform_func(ax.scene)
Expand Down
1 change: 1 addition & 0 deletions test/makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ end
@test ax.limits[] == (nothing, [5, 7])
@test ax.targetlimits[] == BBox(-5, 11, 5, 7)
@test ax.finallimits[] == BBox(-5, 11, 5, 7)
@test_throws MethodError limits!(f[1,1], -1, 1, -1, 1)
end

# issue 3240
Expand Down

0 comments on commit 34e84ea

Please sign in to comment.