From 34e84ea0749ceff42e3068662bc340ee2fac1efc Mon Sep 17 00:00:00 2001 From: Sagnac <83491030+Sagnac@users.noreply.github.com> Date: Sat, 27 Jan 2024 15:45:50 +0000 Subject: [PATCH] Fix a hang due to `limits!` being called recursively 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. --- src/makielayout/blocks/axis.jl | 6 ++++-- test/makielayout.jl | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/makielayout/blocks/axis.jl b/src/makielayout/blocks/axis.jl index 8248577fbb8..53ec8ebe000 100644 --- a/src/makielayout/blocks/axis.jl +++ b/src/makielayout/blocks/axis.jl @@ -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) diff --git a/test/makielayout.jl b/test/makielayout.jl index 33611f38f2a..5c50e90632c 100644 --- a/test/makielayout.jl +++ b/test/makielayout.jl @@ -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