Plots.jl: QPaintDevice: Cannot destroy paint device that is being painted [SOLVED]

Good morning. Anybody here using the Plots.jl package for Julia? I am trying to generate some plots in files without having them display on the screen. I have a sequence of

plt = plot(...)
plot!(plt, ...)
plot!(plt, ...)
savefig(plt, filename)

in a script (not interactive) which invariably leads to errors while running:

QPaintDevice: Cannot destroy paint device that is being painted
Segmentation fault (core dumped)

The actual plots in the files are generated just fine and my program runs fine otherwise but the errors are annoying and the display flickers. I have tried setting the show = false option to all plot calls to no effect.

(I’ve asked this on mastodon where I got some nice answers but nothing so far that has worked unfortunately. I don’t particularly like discourse as it requires me using an overblown web browser… I’m old skool. :wink: )

Solved!

On mastodon, the solution proposed was to add the line

ENV["GKSwstype"]="nul"

at the start and it does the job!

I’ll leave this thread here for others that might run into this problem.