FileDialog locks drive



  • I noticed something today that it causing an issue for me. I think it is by design, but I am not sure how to work around it. I am using a FileDialog to select a folder. Once the folder is selected I dont really need it until another selection is required, but it is a Qml element so it sticks around. The problem is that it grabs a handle to the folder and hangs onto it. I found the process in Process Explorer and verified that the handle stays open. I force closed the handle using Process Explorer and got the warning below.

    QFileSystemWatcher: FindNextChangeNotification failed for "G:\"  (The handle is invalid.)
    

    So it seems that its creating a QFileSystemWatcher and watching for changes. This is an issue for me because I need to modify the drive and it is blocking it. Is there any way to turn this off. Can I just create a FileDialog on the fly and dispose of it when I am done? It doesn't seem like I can manually change the location without user interaction either. Any ideas would be appreciated. I will include my demo project qml file for reference as well.

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    
    ApplicationWindow {
        title: qsTr("Hello World")
        width: 640
        height: 480
        visible: true
    
        FileDialog
        {
            id: folderDialog
            title: qsTr("Please choose a folder")
            selectFolder: true
            
            onAccepted:
            {
                close();
            }
            onRejected:
            {
                close();
            }
        }
        Button
        {
            text: "Test"
            onClicked:
            {
                folderDialog.open();
            }
        }
    }

Log in to reply
 

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