JuliaGraphics / QML.jl

Build Qt6 QML interfaces for Julia programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Qml instance started with Exec_async doesn't close properly

f-ij opened this issue · comments

I need to open my file using exec_async, since I have an interactive simulation displaying and image, and otherwise it won't update the image. However, as opposed to starting just with exec(), if I close the QML window the QML engine is not closed. Due to this, if I try to exec_async() again from the same REPL, I get the error: ERROR: Existing engine, aborting creation. I have to close the REPL and recompile all functions again to open a new window.

On the main branch, there is a function QML.cleanup. After calling that, you can call exec_async again. (It's neither documented nor exported though, so it might change in the future.)

I tried the following in the project QmlJuliaExamples

cd basic
julia --project

and then in Julia, after initiating the project:

include("listmodel-fromjulia.jl") # window pops up
QML.cleanup() # window closes
include("listmodel-fromjulia.jl") # crash

This crashes with

julia> include("listmodel-fromjulia.jl")

[64952] signal (11.2): Segmentation fault
in expression starting at /home/ufechner/repos/QmlJuliaExamples/basic/listmodel-fromjulia.jl:51
unknown function (ip: 0x7f63f5f75040)
unknown function (ip: 0x7f6329ffc58f)
Allocations: 6039630 (Pool: 6033552; Big: 6078); GC: 9
Segmentation fault (core dumped)

@barche Any idea?

Instead of using cleanup directly, you should exit the REPL. After running exec_async, a new REPL is actually started, so exiting that one will bring you back to the original REPL and then you can restart the app. Note that there is still a problem with this, changing model values from Julia causes the stack issue we saw before.