Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-99600

Reg->6: macOS: FileDialog opens in the wrong directory when two FileDialog instances are in use

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P1: Critical
    • None
    • 6.2.3, 6.3.0 Beta1
    • Quick: Dialogs
    • None
    • macOS 12.1 / 12.2 (M1)
    • macOS

    Description

      This is a regression experienced when upgrading Qt from 5.15 to 6.2.2.

      In my application, I have two FileDialogs. One for picking file type A (e.g. documents), one for picking file type B (e.g. pictures).

      The code looks as follows:

      import QtQuick
      import QtQuick.Controls.Basic
      import QtQuick.Dialogs
      import QtCore
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          FileDialog {
              id: documentsDialog
              currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
          }
      
          Button {
              id: documentsButton
              text: qsTr("Open documents")
              onClicked: documentsDialog.open()
          }
      
          FileDialog {
              id: picturesDialog
              currentFolder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
          }
      
          Button {
              id: picturesButton
              text: qsTr("Open pictures")
              onClicked: picturesDialog.open()
      
              anchors.top: documentsButton.bottom
              anchors.topMargin: 16
          }
      }
      

      When I click the buttons to open the respective dialogs, Qt doesn't always open the FileDialogs at the correct paths specified via the currentFolder properties.

      Reproduction:

      1. Click "Open documents" → Dialog opens in Documents folder
      2. Click "Open pictures" → Dialog opens in Pictures folder
      3. Click "Open documents" → Dialog opens in Documents or Pictures folder, depending on your luck
      4. Click "Open pictures" → Dialog opens in Documents folder (no luck involved)
      5. Click "Open documents" → Dialog opens in Pictures folder
      6. Click "Open documents" → Dialog opens in Documents folder
      7. Click "Open pictures" → Dialog opens in Documents folder
      8. Click "Open pictures" → Dialog opens in Pictures folder

      As you can see, at some point the file picker always lags one step behind.

      I haven't tested this on any other platform than macOS.

      This didn't happen when using the Qt 5.15 FileDialog.

      Workaround

      Wrap each FileDialog in a Loader, load them when necessary and unload them afterwards.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            richard Richard Moe Gustavsen
            nikwen Niklas Wenzel
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes