[BUG?] Dangerous behaviour of FolderListModel when the folder specified is invalid
-
Hi everyone! I'm developing a QML application and need to get some images placed in
/tmp/myApp/
, so I used a FolderListModel and setfolder: "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 -
Hi,
I would say it's a surprising behaviour.
Which version of Qt are you using ?
-
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.
-
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.