Skip to content

Commit

Permalink
fix another incorrect free
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jan 7, 2025
1 parent c07e4b9 commit 4d106cf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions GLMakie/src/GLAbstraction/GLTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ include("GLRenderObject.jl")
####################################################################################
# freeing

# const TRACE_FREE = Ref(false)

function free(x::T, called_from_finalizer = false) where {T}
# don't free if already freed (this should only be set by unsafe_free)
x.id == 0 && return
Expand All @@ -439,6 +441,17 @@ function free(x::T, called_from_finalizer = false) where {T}
# to be active or alive here, because unsafe_free() may also do
# cleanup that doesn't depend on context

# if TRACE_FREE[]
# try
# error("tracing...")
# catch e
# bt = catch_backtrace()
# Threads.@spawn begin
# @warn "free(::$T)" exception = (e, bt)
# end
# end
# end

# This may be called from the scene finalizer in which case no errors and
# no printing allowed from the current task
if called_from_finalizer
Expand Down
4 changes: 2 additions & 2 deletions GLMakie/src/gl_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ function get_texture!(context, atlas::Makie.TextureAtlas, called_from_finalizer
catch e
if called_from_finalizer
Threads.@spawn begin
@error "Cached atlas textures should be removed explicitly!" exception = (e, catch_backtrace())
@error "Cached atlas textures should be removed explicitly! Dropping $(tex_func[1].id)" exception = (e, catch_backtrace())
end
else
@error "Cached atlas textures should be removed explicitly!" exception = (e, catch_backtrace())
@error "Cached atlas textures should be removed explicitly! Dropping $(tex_func[1].id)" exception = (e, catch_backtrace())
end
end
tex_func[1].id = 0 # Should get cleaned up when OpenGL context gets destroyed
Expand Down
1 change: 1 addition & 0 deletions GLMakie/src/postprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ function construct(::Val{:FXAA1}, screen, framebuffer, inputs, parent)
loadshader("postprocessing/postprocess.frag"),
view = Dict("FILTER_IN_SHADER" => filter_fxaa_in_shader ? "#define FILTER_IN_SHADER" : "")
)
filter_fxaa_in_shader || pop!(inputs, :objectid_buffer)
robj = RenderObject(inputs, shader, PostprocessPrerender(), nothing, screen.glscreen)
robj.postrenderfunction = () -> draw_fullscreen(robj.vertexarray.id)

Expand Down
2 changes: 1 addition & 1 deletion GLMakie/test/glmakie_refimages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ end
end

@reference_test "render stage parameters with SSAO postprocessor" begin
GLMakie.closeall()
GLMakie.closeall() # (mostly?) for recompilation of plot shaders
GLMakie.activate!(ssao = true)
f = Figure()
ps = [Point3f(x, y, sin(x * y + y-x)) for x in range(-2, 2, length=21) for y in range(-2, 2, length=21)]
Expand Down

0 comments on commit 4d106cf

Please sign in to comment.