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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 447 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.
  • T Offline
    T Offline
    tubbadu
    wrote on 6 Jul 2022, 09:24 last edited by tubbadu 7 Jun 2022, 11:34
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Jul 2022, 19:14 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 9 Jul 2022, 07:06
      0
      • S SGaist
        6 Jul 2022, 19:14

        Hi,

        I would say it's a surprising behaviour.

        Which version of Qt are you using ?

        T Offline
        T Offline
        tubbadu
        wrote on 9 Jul 2022, 07:06 last edited by
        #3

        @SGaist Qt 5.15.3

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Jul 2022, 18:45 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 13 Jul 2022, 11:25
          0
          • S SGaist
            9 Jul 2022, 18:45

            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 13 Jul 2022, 11:25 last edited by
            #5

            I'll try, thanks!

            1 Reply Last reply
            0

            1/5

            6 Jul 2022, 09:24

            • Login

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