Repository navigation
Segfault when exiting Julia after replacing a JuliaItemModel #218
Copy link
Copy link
Closed
Labels
Description
Activity
For completeness:
julia> versioninfo() Julia Version 1.11.5 Commit 760b2e5b739 (2025-04-14 06:53 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz WORD_SIZE: 64 LLVM: libLLVM-16.0.6 (ORCJIT, skylake) Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores) julia> Pkg.status() [336ed68f] CSV v0.10.15 [1f15a43c] CxxWrap v0.16.2 [3b531cbf] DataConvenience v0.3.6 [a93c6f00] DataFrames v1.7.0 [c601a237] Interact v0.10.5 [510215fc] Observables v0.5.5 [d96e819e] Parameters v0.12.3 [2db162a6] QML v0.9.2 [2913bbd2] StatsBase v0.34.4 [f3b207a7] StatsPlots v0.15.7I can reproduce the issue.
Reacted by tetrakai1This is a crosspost of my workaround from the discourse thread.
This works. First clear the array in QML, then push to it from Julia:
using QML # const qml_file = joinpath(pwd(), "code", "qml", "test.qml") function update_props() props["fruits"] = fruits2 end # First clear props in QML function update_props() [push!(props["fruits"], fruits2[i]) for i in 1:length(fruits2)] end function main(qml_file, props) loadqml(qml_file, props = props) exec() end mutable struct Fruit name::String cost::Float64 end fruits = JuliaItemModel([Fruit("apple", 1.0), Fruit("orange", 2.0)]) fruits2 = JuliaItemModel([Fruit("banana", 1.0), Fruit("pear", 2.0)]) props = JuliaPropertyMap("fruits" => fruits) @qmlfunction update_props # main(qml_file, props) mktempdir() do folder path = joinpath(folder, "test.qml") write(path, """ import QtQuick import QtQuick.Controls import QtQuick.Layouts import org.julialang ApplicationWindow { id: mainWin title: "My Application" width: 400 height: 400 visible: true ColumnLayout{ anchors.fill: parent Button { height: 200 Layout.fillWidth: true text: "Update Fruit" onClicked: { // First clear then update from julia props.fruits.clear() Julia.update_props() } } ListView { model: props.fruits Layout.fillHeight: true Layout.fillWidth: true delegate: Row { Text { text: name } } } } } """) main(path, props) end
Still there should be a warning instead of that segfault.
I confirm that I can reproduce this, it's probably a bug related to not disconnecting notification functions when changing the property, so it's a QML.jl bug, not wrong usage :)
Reacted by tetrakai1Fixed in QML.jl v0.13.2.
Reacted by tetrakai1
Hi,
My Qt app runs fine, but then after closing it there is segfault when exiting the Julia session.
As discussed here
MWE 1:
MWE 2:
It isn't clear whether this is misusing the package or a bug.
Thanks.