QML FileDialog memory leak



  • Valgrind detects a memory leak in FileDialog. Is it a problem or just incorrect usage of dialog?

    main.cpp:

    #include <QApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        return app.exec();
    }
    

    main.qml:

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        Button {
            id: button1
            text: qsTr("Press Me 1")
            onClicked: saveFileDialog.visible = true
        }
        FileDialog {
            id: saveFileDialog
            title: qsTr("Please choose a file")
            selectExisting: false
            selectMultiple: false
            nameFilters: [ qsTr("XML files (*.xml)"), qsTr("All files (*)") ]
            onAccepted: {
                console.log(saveFileDialog.fileUrl)
            }
            onRejected: {
                console.log("Cancel")
            }
        }
    }
    

    Valgrind output:

    136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 10,536 of 11,981
      в main в /home/blex/ml/main.cpp:8
      1: operator new(unsigned long) в /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
      2: QQmlFileSelectorPrivate::QQmlFileSelectorPrivate() в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      3: QQmlFileSelector::QQmlFileSelector(QQmlEngine*, QObject*) в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      4: QQmlApplicationEnginePrivate::init() в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      5: main в /home/blex/ml/main.cpp:8
    

    Thanks



  • Having the same issue even with simpler HelloWorld application.

    main.qml:

    import QtQuick 2.3
    import QtQuick.Window 2.2
    
    Window {
        visible: true
    
        MouseArea {
            anchors.fill: parent
            onClicked: {
                Qt.quit();
            }
        }
    
        Text {
            text: qsTr("Hello World")
            anchors.centerIn: parent
        }
    }
    

    Valgrind reports exact the same error as you post.



  • Hi! Looks like this isn't in the bug tracker yet. Please report it to bugreports.qt.io.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.