Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up some more observables for blocks and axis #3475

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/makielayout/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ end
function init_observable!(@nospecialize(block), key::Symbol, @nospecialize(OT), @nospecialize(value::Observable))
obstype = observable_type(OT)
o = Observable{obstype}()
map!(o, value) do v
map!(block.blockscene, o, value) do v
convert_for_attribute(obstype, v)
end
setfield!(block, key, o)
Expand Down
3 changes: 2 additions & 1 deletion src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ function initialize_block!(ax::Axis; palette = nothing)
notify(ax.xscale)

# 3. Update the view onto the plot (camera matrices)
onany(update_axis_camera, camera(scene), scene.transformation.transform_func, finallimits, ax.xreversed, ax.yreversed, priority = -2)
onany(update_axis_camera, blockscene, camera(scene), scene.transformation.transform_func, finallimits,
ax.xreversed, ax.yreversed; priority=-2)

xaxis_endpoints = lift(blockscene, ax.xaxisposition, scene.viewport;
ignore_equal_values=true) do xaxisposition, area
Expand Down
14 changes: 14 additions & 0 deletions test/makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,17 @@ end
rethrow(e)
end
end

@testset "Block attribute conversion observable cleanup" begin
limits = Observable((-1.0, 1.0, -1.0, 1.0))
for _ in 1:5
fig = Figure()
for i in 1:5
for j in 1:5
ax = Axis(fig[i, j]; limits)
end
end
empty!(fig)
end
@test isempty(limits.listeners)
end
Loading