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

    • Type: Bug
    • Status: Open
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 6.2.3, 6.3.0 Beta1
    • Fix Version/s: None
    • Component/s: Quick: Dialogs
    • Labels:
      None
    • Environment:
      macOS 12.1 / 12.2 (M1)
    • Platform/s:
      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

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

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes