Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML Application exit errors



  • Greetings!
    I’ve stuck with problem creating QML application for Linux. Use Qt 5.11.
    The problem started, after I created utility class in QML for more convenient dynamical object creation.

    ComponentCreator.qml

        function createObject(path, parent)
        {
            let resultObject = undefined
    
            const component = Qt.createComponent(path, Component.PreferSynchronous, parent);
    
            switch (component.status)
            {
                case Component.Ready:
                    return component.createObject(parent);
                case Component.Error:
                    console.warn(qsTr("Component creation error:"), component.errorString());
                    return undefined
                default:
                    return undefined
            }
        }
    
        function createInputDataField(parent)
        {
            return createObject("qrc:/qml/Components/Input/InputDataField.qml", parent)
        }
    

    When close my QML app, I received this horrible stack trace output:
    9bfee5ff-5674-4e2e-b4c5-d85f8d7feae1-image.png

    I thought, that problem could be connected with destruction of QQmlApplicationEngine. So I decided to wait until engine will be destroyed when closing app. It doesn’t really help, but console output became like this:
    db40615a-7f08-4a35-959a-ab71a59230b4-image.png
    This looks like parent destroyed, but created item - not.

    The thing is, when I place creation method in file, where object should be created, there are no more errors. I can only suggest, that there is a problem with contexts, but in what way - have no idea.

    I’ll be very grateful, if someone can give any ideas what causes that behavior.
    Thanks!



  • hi
    @Vasilevs said in QML Application exit errors:

    I created utility class in QML for more convenient dynamical object creation.

        const component = Qt.createComponent(path, Component.PreferSynchronous, parent);
        switch (component.status)
        {
    

    try to connect a function to your component's statusChanged signal instead of checking the status just after the creation, see here https://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html

    @Vasilevs said in QML Application exit errors:

    This looks like parent destroyed, but created item - not.

    you can verify it with the debugger