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. [BUG?] Dangerous behaviour of FolderListModel when the folder specified is invalid
QtWS25 Last Chance

[BUG?] Dangerous behaviour of FolderListModel when the folder specified is invalid

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 433 Views
  • 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.
  • T Offline
    T Offline
    tubbadu
    wrote on last edited by tubbadu
    #1

    Hi everyone! I'm developing a QML application and need to get some images placed in /tmp/myApp/, so I used a FolderListModel and set folder: "file:///tmp/myApp/", and everything works fine if the directory does exist. However, if something before in the application went wrong and the directory doesn't exist, instead of throwing an error or assuming an error state, it just decide to read all the files in the directory where I launched the executable from (my home folder usually, or my build folder if I run it from Qt Creator)

    Is this behaviour correct? isn't it a bit dangerous, as it may access files that the user absolutely doesn't want it to? is there a way to avoid it?

    I'm on Fedora36 KDE spin

    For example, this simple script:

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import Qt.labs.folderlistmodel 2.5
    
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
        FolderListModel{
            folder: "file:///tmp/myApp/"
            Component.onCompleted: console.log("folder: " + folder)
        }
    }
    

    prints qml: folder: file:///home/tubbadu/code/Qt/build-myApp-Desktop-Debug because /tmp/myApp/ does not exists
    if instead I create that directory then it correctly reads it

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I would say it's a surprising behaviour.

      Which version of Qt are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        I would say it's a surprising behaviour.

        Which version of Qt are you using ?

        T Offline
        T Offline
        tubbadu
        wrote on last edited by
        #3

        @SGaist Qt 5.15.3

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you retest with a more recent version ?

          If memory serves well 5.15.5 was released some days ago.

          Even with Qt 6 to see if the behaviour changed.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you retest with a more recent version ?

            If memory serves well 5.15.5 was released some days ago.

            Even with Qt 6 to see if the behaviour changed.

            T Offline
            T Offline
            tubbadu
            wrote on last edited by
            #5

            I'll try, thanks!

            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