# Avoiding segfault on exit when using QML.jl

**URL:** <https://discourse.julialang.org/t/avoiding-segfault-on-exit-when-using-qml-jl/128737>\
**Category:** General Usage\
**Tags:** question, segfault, qml\
**Created:** [May 6, 2025, 12:10am UTC](https://discourse.julialang.org/t/avoiding-segfault-on-exit-when-using-qml-jl/128737 "2025-05-06T00:10:01Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Tetrakai](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Post date:** [May 6, 2025, 6:54pm UTC](https://discourse.julialang.org/t/avoiding-segfault-on-exit-when-using-qml-jl/128737/7 "2025-05-06T18:54:30Z")

</div>

Ok… now it is actually using the temp folder. Run this, click the button, close the Qt window, then exit julia. You should see the segfault.

MWE:

```julia
using QML

# const qml_file = joinpath(pwd(), "code", "qml", "test.qml")

function update_props()
    props["fruits"] = 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: { 
                                  Julia.update_props()
                                  console.log("Value:", props.fruits) 
                              }
                         }
                          ListView {
                              model: props.fruits
                              Layout.fillHeight: true
                              Layout.fillWidth: true
                              delegate: Row {
                                  Text {
                                      text: name
                                  }
                              }
                          }
                      }
                  }
                  """)
            main(path, props)
          end

```

Error:

```julia
[2151785] signal 11 (1): Segmentation fault
in expression starting at none:0
unknown function (ip: 0x20)
_ZN5jlcxx6detail11CallFunctorIvJPN7qmlwrap14JuliaItemModelEEE5applyEPKvNS_13WrappedCppPtrE at /home/user/.julia/artifacts/7bc654121da55f7ea29f116c66155e8e5ebb43ff/lib/libjlqml.so (unknown line)
Allocations: 5190401 (Pool: 5189939; Big: 462); GC: 6
Segmentation fault (core dumped)

```

---

_[View the full topic](https://discourse.julialang.org/t/avoiding-segfault-on-exit-when-using-qml-jl/128737)._
