Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML FileDialog memory leak
Forum Updated to NodeBB v4.3 + New Features

QML FileDialog memory leak

Scheduled Pinned Locked Moved QML and Qt Quick
qmlfiledialogmemory leak
3 Posts 3 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blex
    wrote on last edited by
    #1

    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


    Oleksiy Balabay

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Approximator
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved