Skip to content

Commit 0180298

Browse files
authored
Merge pull request #182 from JuliaImGui/makie-precompilation
Tear down GLMakie figures properly during precompilation
2 parents 836a471 + ec9618e commit 0180298

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CImGui"
22
uuid = "5d785b6c-b76f-510e-a07c-3070796c7e87"
33
authors = ["Yupei Qi <qiyupei@gmail.com>"]
4-
version = "6.2.0"
4+
version = "6.2.1"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

docs/src/_changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ CurrentModule = CImGui
66
This documents notable changes in CImGui.jl. The format is based on [Keep a
77
Changelog](https://keepachangelog.com).
88

9+
## [v6.2.1] - 2025-10-15
10+
11+
### Fixed
12+
- Fixed teardown of GLMakie figures by the Makie extension ([#182]).
13+
914
## [v6.2.0] - 2025-09-27
1015

1116
### Fixed

ext/GlfwOpenGLBackend.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ig._current_window(::Val{:GlfwOpenGL3}) = _window
6565

6666
function renderloop(ui, ctx::Ptr{lib.ImGuiContext}, ::Val{:GlfwOpenGL3};
6767
hotloading=true,
68-
on_exit=nothing,
68+
on_exit=Returns(nothing),
6969
clear_color=Cfloat[0.45, 0.55, 0.60, 1.00],
7070
window_size=(1280, 720),
7171
window_title="CImGui",
@@ -192,11 +192,11 @@ function renderloop(ui, ctx::Ptr{lib.ImGuiContext}, ::Val{:GlfwOpenGL3};
192192
catch e
193193
@error "Error in CImGui $(ig._backend) renderloop!" exception=(e, catch_backtrace())
194194
finally
195-
for func in vcat(ig._exit_handlers, isnothing(on_exit) ? [] : [on_exit])
195+
for func in vcat(ig._exit_handlers, [on_exit])
196196
try
197197
func()
198198
catch ex
199-
@error "Error in exit handler!" exception=(ex, catch_backtrace())
199+
@error "Error in CImGui.jl exit handler!" exception=(ex, catch_backtrace())
200200
end
201201
end
202202

ext/MakieIntegration.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const makie_context = Dict{ig.ImGuiID, ImMakieFigure}()
3535
function destroy_context()
3636
for imfigure in values(makie_context)
3737
empty!(imfigure.figure)
38+
GLMakie.destroy!(imfigure.screen)
3839
end
3940

4041
empty!(makie_context)
@@ -293,15 +294,18 @@ end
293294
ig.set_backend(:GlfwOpenGL3)
294295
ctx = ig.CreateContext()
295296

296-
ig.render(ctx; window_title="CImGui/Makie precompilation workload", opengl_version=v"3.3") do
297+
# Note that we explicitly pass `on_exit=destroy_context` since
298+
# __init__() doesn't run during precompilation.
299+
ig.render(ctx; window_title="CImGui/Makie precompilation workload",
300+
opengl_version=v"3.3",
301+
on_exit=destroy_context) do
297302
ig.Begin("Foo")
298303
ig.MakieFigure("plot", f)
299304
ig.End()
300305

301306
return :imgui_exit_loop
302307
end
303308

304-
destroy_context()
305309
ig._backend = nothing
306310
end
307311
end

0 commit comments

Comments
 (0)