diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index bd01bbdedc3..16a0add2396 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -343,7 +343,8 @@ function singleton_screen(debugging::Bool) if !isempty(SINGLETON_SCREEN) @debug("reusing singleton screen") screen = SINGLETON_SCREEN[1] - close(screen; reuse=false) + stop_renderloop!(screen; close_after_renderloop=false) + empty!(screen) else @debug("new singleton screen") # reuse=false, because we "manually" re-use the singleton screen! @@ -885,8 +886,6 @@ function stop_renderloop!(screen::Screen; close_after_renderloop=screen.close_af c = screen.close_after_renderloop screen.close_after_renderloop = close_after_renderloop screen.stop_renderloop = true - screen.close_after_renderloop = c - # stop_renderloop! may be called inside renderloop as part of close # in which case we should not wait for the task to finish (deadlock) if Base.current_task() != screen.rendertask @@ -895,6 +894,7 @@ function stop_renderloop!(screen::Screen; close_after_renderloop=screen.close_af screen.rendertask = nothing end # else, we can't do that much in the rendertask itself + screen.close_after_renderloop = c return end