diff --git a/GLMakie/test/unit_tests.jl b/GLMakie/test/unit_tests.jl index ea16da8f284..c8d71e1ff5f 100644 --- a/GLMakie/test/unit_tests.jl +++ b/GLMakie/test/unit_tests.jl @@ -102,6 +102,7 @@ end text!(ax, [Point2f(2)], text=["hi"]) screen = display(fig) empty!(fig) + @test screen in fig.scene.current_screens @testset "all got freed" begin for (_, _, robj) in screen.renderlist for (k, v) in robj.uniforms diff --git a/src/figures.jl b/src/figures.jl index fe0f6cece90..4c0e8cf78d1 100644 --- a/src/figures.jl +++ b/src/figures.jl @@ -152,7 +152,10 @@ function resize_to_layout!(fig::Figure) end function Base.empty!(fig::Figure) + screens = copy(fig.scene.current_screens) empty!(fig.scene) + # The empty! api doesn't gracefully handle screens for e.g. the figure scene which is supposed to be still used! + append!(fig.scene.current_screens, screens) empty!(fig.scene.events) foreach(GridLayoutBase.remove_from_gridlayout!, reverse(fig.layout.content)) trim!(fig.layout)